Where are added archetypes stored in IntelliJ? - maven-2

When creating a Maven-based project/module in IDEA you can click "Add archetype". Where are these new archetype values stored? I looked in my ~/.m2/repository but I don't think that's it…
Bonus question: what are the best practices around "Add archetype"? Just curious. I'm prone to skipping this in IDEA and just using mvn from the command line.

The information about added archetypes are stored in the file
Linux: ~/.IntelliJIdea10/system/Maven/Indices/UserArchetypes.xml
Mac: ~/Library/Caches/IntelliJIdea12/Maven/Indices/UserArchetypes.xml
You can edit this file directly. You need to restart IntelliJ after editing this file. There is no other way at this point in time to modify this information, see issue http://youtrack.jetbrains.net/issue/IDEA-60985
The archetype plugins will be downloaded to your local repository.

And in Windows (7) you'll find them here: C:\Users\<username>\.IdeaI<versionid>\system\Maven\Indices\UserArchetypes.xml

In Windows 10 (2020):
Looks like newer versions of IntelliJ have switched to AppData folder.
C:\Users\<username>\AppData\Local\JetBrains\IdealC<version>\Maven\Indices
In Windows 10 (Older versions):
C:\Users\<username>\.IntelliJIdea<version>\system\Maven\Indices

intelliJ OSX: (vers. 2020.1)
cd ~/Library/Caches/JetBrains/IntelliJIdea2020.1/Maven/Indices/

Related

IntelliJ shows decompiled .class file instead of source code

I am having issues with IntelliJ - it shows me a "decompiled" version of the class instead of its source code if I ctrl+click the class.
This is what I see:
I am trying to open regular JDK source files.
The most relevant issue I found is explained here: Java sources replaced by decompiled files in Intellij
The most detailed answer I've found so far is there as well.
Yet it doesn't work for me:
Bytecode Viewer plugin is off.
Java Bytecode Decompiler plugin is off.
Platform, Project and Module all have same JDK version setup.
I have two JDKs available in IntelliJ: jdk1.8.0_161 and jbsdk8u112b287.2_windows_x86 (bundled with IntelliJ, but comes without src.zip). Tried with both (had to specify src.zip of jdk1.8.0_161 for jbsdk8u112b287.2_windows_x86) - no luck
src.zip is not corrupt - I can open it via WinRAR
When added jdk1.8.0_161 to IntelliJ, it automatically found src.zip. When manually adding src.zip to jbsdk8u112b287.2_windows_x86 Sourcepath tab - it started "Scanning for roots", but warned me that it "cannot determine what kind of files the chosen items contain" and offered me to "attach them as 'Sources'" so I agreed.
Tried File > Invalidate Caches / Restart... - same result.
Same issue in 2017.3 and fresh 2018.1 versions of IntelliJ.
Providing path for Documentation makes IntelliJ look for the documentation in the path specified. So it works as it should for both of JDKs. But not for sources.
Everything else works/compiles properly.
My settings:
1. Get the source files
Make sure you have downloaded and installed the source files of the JDK.
I'm on Arch Linux and installed them with pacman -S openjdk8-src which put a src.zip into /usr/lib/jvm/java-8-openjdk/. We'll use that zip file in the next step.
To list source packages of different JDK versions, do pacman -Ss "openjdk.*-src".
See this question on how to get the source files for your specific platform.
2. Point IntelliJ to the source files
In your module settings (open them with F4) under "Platform Settings" → "SDKs" → "Sourcepath", add the zip file containing the JDK source to your project JDK (be sure to pick the right JDK if IntelliJ lists more than one JDK) using the button with the plus sign:
3. Jump into the source
Select a JDK class, like Comparator, using IntelliJ's Search Everywhere or Ctrl+b with the cursor on the name of the class.
I also have the same problem. The problem for my case is that Project SDK is set to 13 [Invalid]. After I can Project SDK to a valid SDK. My problem is solved.
I tried all the things mentioned at other places for this but at the end I was doing a silly mistake. Intellij was pointing to JDK 11 for which there was no source code (I had both the SDKs 8 & 11). I removed JDK 11 and pointed to JDK 8. JDK had the source code, thus now I can see the source code on ctrl click. Also, I had disabled the bytecode viewer and decompiler plugins. Hope this helps some one.
This also happens for large files - IDEA decides to decompile them instead if indexing sources, which can take ages.
If you're willing to accept the drawdown, adding the following in Help | Edit Custom Properties might fix the problem:
idea.max.intellisense.filesize=4096
On ubuntu there was java version “OpenJDK” when I changed to “Oracle Java”, the error went away and javadoc returned
I meet same problem and finally it gone after I copy JDK to another folder and change config in IntelliJ. I think maybe cause there is a space in path before, because it is installed under "Program Files" folder.
For downloading the source code of class files belong to jar you can use download source option present on top right corner in the de-compiled class file.
On my Windows 10, expand maven:
For me going to File -> Project Structure -> Project -> SDK -> Add SDK -> Download JDK and selecting Oracle OpenJDK solved the problem. Prior to that I had a different JDK selected and apparently it didn't include source code
If you are in a maven project make sure in the project structure all the complied folders are in the excluded section.
I suggest to use Linux Instead of windows. It's easy to find and download Java.
If you are using Linux, you can download SDKMAN
Install Java by SDKMAN
# find version
$ sdk list java
# download
$ sdk install java x.y.z-amzn
ctrl+alt+shift+s add JDK
Switch project JDK
If you are using maven , Right click on Project explorer -> choose Maven -> chick on "reload projects"
This did the trick for me:
Make sure you select the option "Project Files" (instead e.g. "Project").

Invalid JDK configuration found, while importing a project via Gradle

I have installed IntelliJ and I need to import a Gradle project.
I have build the gradle project using command prompt with the gradlew build command.
At the IntelliJ welcome page, I have proceeded with proper instructions, and when I choose "Finish". I get the following error:
Invalid Gradle JDK configuration found. Open Gradle Settings JAVA_HOME ennvironment variable not set.
When I click on "Open Gradle Settings" it pop up with error of Not found with a path under IntelliJ directory in Program files and searching in jre/jre/bin/....etc.
Deleting .gradle and .idea will likely solve the problem.
So:
Close the project
Go to the project dir and delete .gradle and .idea
Get back and re-open the project using the IDE
These two must be generated locally on your PC (Some content of .idea might be version controlled though) and not pulled from a remote or somewhere else (Also they should be in .gitignore).
In my case the reason was that these two folders were generated on another computer and I had opened a project with these two folders existing before.
Just found the solution :
Create an empty Gradle project, then go to "Project Structure" and check the path to JDK (it should be valid, if it isn't you can add your own path).
Then build this empty project, wait and once done, close IntelliJ.
Relaunch it and try to import/open your Gradle project, now it should work.
You don't need to create a new project to fix this. You can do it from the main window (Configure -> Project Defaults -> Project Structure):
Then, on SDKs, set the appropriate JDK home path:
If you are on a Mac, click on the button with 3 dots and select the folder /Library/Java/JavaVirtualMachines/jdk1.8.0_141.jdk/Contents/Home.
I've found this here:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000266650-invalid-gradle-jdk-configuration-found
Mac OS X Solution:
I had the same issue and fixed it by setting the JAVA_HOME environment variable using the command:
launchctl setenv JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/
Refer to this answer on how to set environment variables in Mac OS X:
Setting environment variables in OS X?
Close the project
Go to the project dir and delete
.gradle
.idea
Get back and re-open the project using the IDE
I recently had the same problem while importing a Gradle project. The trick was the remove the quotes from the JAVA_HOME variable. So instead of "C:\Program Files\Java\jdk1.8.0_66" my path now contains only the plain path C:\Program Files\Java\jdk1.8.0_66.
To add to the previous responses, if you want to prevent this problem when cloning a repository in Git, you can simply remove .idea/misc.xml from your .gitignore file. This contains information about the project jar. For example:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_10" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
</project>
For my case, I just restart the IDE and it works. It automatically download Gradle to suit the project version.
I had the same problem on the fresh installed Windows OS.
I did not have a JDK at all and forgot to check it invalid JDK configuration .
By default, you can check the Project configuration. If it is empty NO_SDK_ProjectStructure try to download JDK from Oracle web site and configure your project structure
I have faced same problem for tomcat 9 with my project based on Gradle.
You can easily rectify the problem by configuring the application.properties file with the following code.
location - src/main/resources/application.properties
server.port = 9090
spring.security.user.name= admin
spring.security.user.password= password
My issue was not addressed by the above solution, instead root cause was that I've imported settings from my old system and internal Intellij configuration was invalid because first jdk that it had in the list in jdk.table.xml pointed to a wrong path.
To fix this you should find this file in the intellij config folder and then simply open it with an editor and remove whole block related to the bad jdk version.
Close the project you are working on and then create another new project and build it and then close it and go back to your old project and it will work.
Comment this code on gradle.properties, the Issue was gone.
#org.gradle.java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_141.jdk/Contents/Home
I was getting:
Invalid JDK: /home/sz97/idea-IC-223.7571.182/jbr/bin/jlink is not a file!
Ensure JAVA_HOME or buildSettings.javaHome is set to JDK 15 or newer
As mentioned by Mahdi-Malv, delete .gradle & .idea folders from the project directory.
Then delete other SDKs from File > Project Structure > Platform Settings > SDKs keeping the only required one.
Finally change the SDK version from Project Structure > Project Settings > Project.
This may solve the problem.

intellij - java: Cannot find JDK '1.7' for module

I've just installed IntelliJ on Windows 8 (and 7). I then use the 'Java Hello World' Sample as my project.
I then selected the JDK that was installed (C:\Program Files\Java\jdk1.7.0_10). Project creates successfully and I can see all the classes associated with the project etc. When I "make the project" I get the following error:
Compilation completed with 1 error and 0 warnings in 2 sec
1 error
0 warnings
java: Cannot find JDK '1.7' for module 'TEST'
No matter what I do I cannot compile any Java code under Windows8/IntelliJ
I have tried the following:
Invalidating cache.
Switching to 32bit JDK instead of 64bit
Idea64.exe instead of idea.exe
Installing 1.6 incase it was a 1.7 issue??
Changed the JAVA_HOME to point to different versions (ie currently C:\Program Files\Java\jdk1.7.0_10)
I'm lost as to why this is happening.
project structure > project > choose correct jdk
or ctrl+alt+shift+s > project> choose correct jdk
also platform settings > SDK's >and make sure 1.7 is there.
Found the root of the problem. Turns out Windows 8 under parallels shares the same Desktop as OSX. This confused IntelliJ somehow and as a result it couldn't compile properly.
In parallels by removing the "Desktop" shared under Configure this then resolves the issue.
In case you want to still share the documents & desktop, the solution is to modify the idea.properties file (for instance, under C:\Program Files (x86)\JetBrains\IntelliJ IDEA 12.1\bin\idea.properties ), and change the following properties to point to different a location that is specific to the OS in which you are working:
idea.config.path=
idea.system.path=
idea.plugins.path=
idea.log.path=
I also copied the previous folder (on my computer it was under
\\psf\Home\.IntelliJIdea12
) to the new location to preserve all settings.
Update: I had the same problem after I installed IntelliJ Idea 13. I moved the .IntelliJIdea13 folder to c:\Users\costa from \\psf\Home, then I modified the C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.0\bin\idea.properties file:
idea.config.path=C:/Users/costa/.IntelliJIdea13/config
idea.system.path=C:/Users/costa/.IntelliJIdea13/system
idea.plugins.path=C:/Users/costa/.IntelliJIdea13/config/plugins
idea.log.path=C:/Users/costa/.IntelliJIdea13/system/log
I made the error while editing idea.properties to leave a whitespace at the end of my personally added idea.config.path=../.IdeaIC/config line.
This resulted exactly in the Cannot find JDK '...' for module error message.
I needed to "trim" the line manually, just deleted the whitespace, restarted IntelliJ and everything worked fine again.
I found this while scanning the idea.log file where I found java.io.FileNotFoundException: C:\Software\IntelliJ IDEA Community Edition 14.1.3\.IdeaIC\config \tasks\root.contexts.zip
In my case, Idea said "Failed to save settings" (probably due to a lot of projects being open. After that, it could not run tests with "Cannot find JDK '1.8' for module XXX" message. Idea restart solved the issue for me.
I believe this is an IntelliJ bug.
This isn't a fix, but you can work around this by going to Settings > Compiler, and disabling 'Use External Build'.
It seems that sometimes Intellij (or the user:-)) is getting confused when importing settings, especially if you change the paths where the jdk resides (for me it happened during a migration to a new Linux environment).
The only way I could correct this was to delete the user's settings folder.
In Linux :
I removed the folder (and subfolders): ~/.IntelliJIdea12/
Of course this would remove the saved settings, licenses e.t.c.

Maven Artifact Search is always empty

When using Alt-Insert to insert a dependency into the POM, the Artifact Search is always completely blank regardless of what I search for.
I tried to add repo1 to Settings->Maven->Repository Services, it says "no repository found." I find that hard to believe.
I've also tried to "update" my local repository but that results in an error.
FYI I'm using Community Edition Snapshot.
Thanks!
If you have a brand new IntelliJ install and have never updated your Maven Repository, notice that there is a little "Update" button to the right that becomes clickable when you click on each repository.
Preferences > Build, Execution, Deployment > Build Tools > Maven >
Repositories
The important one is the https://repo.maven.apache.org/maven2/ remote repository, make sure you update it.
I used Artifactory to generate a settings.xml for me, and by default it pointed me to the "libs-releases" repository.
Instead want my "releases" repository to point to the much larger virtual repository "remote-repos."
All it took was a simple change to the options of the "Generate Settings" function.
Weird. The Artifact Search is working fine for me with IntelliJ Community Edition, at least for artifacts from the central repo that has been indexed:
And as you can see above, all repositories declared in POMs known by IntelliJ are listed.
There might be something wrong with your Maven settings. This is a wild guess but is your Maven home directory properly defined? Same for the user settings file? Is Maven actually working fine under IntelliJ?
Solved - by reinstalling Intellij Idea
Search for class tab in Maven Artifact Search popup was always empty
Solution in linux:
remove idea folder (for me it was ~/idea-YOUR_VERSION_HERE)
remove ~/.IntelliJIdeaYOUR_VERSION_HERE folder (settings)
download new version form jetbrains.com, unzip, run installer from bin
It appears to be a blocked port, as I am using my own artifactory repository. Of course, the port it is using looks to be completely undocumented, but WireShark shows it to be 58754. Sounds random, I hope it isn't!

IntelliJ bad plugin how to start

Hi I have just started using IntelliJ again and have version 9. I just installed the Mercurial plugin and now the ide won't start anymore.
Has an error of
Fatal error initializing class com.intellij.openapi.actionSystem.ActionManager:
java.lang.VerifyError: class com.dcx.hg.MercurialVcs overrides final method getName.()Ljava/lang/String;
I now know that I should be using the plugin hg4idea
Is there a way I can remove this plugin so I can start the ide, I am sure there must be..
Thanks in advance.
I am running on a Mac, the Plugin directory is located in ~/Library/Application Support/IntelliJIDEA60/ You can just delete the offending plugin. Note, depending on your edition of the IDE, the directory may be different. For example, IdeaIC2016.3
Version 11 for Windows stores plugins also in c:\Users\<username>\.IntelliJIdea11\config\plugins\ so delete plugins from that location as suggested by #duffymo.
If you look in the directory where you installed IntelliJ, you'll see a /plugins directory. Perhaps if you delete the Mercurial plugin folder you'll be able to restart the UI. Worth a try.
NOTE: Check here for OS/version related plugin path.
Ran into the same problem with another plugin. The solution was to remove the offending plugin folder or jar from the Plugins folder - see the exact location below for your OS.
The locations of the user plugins folder for different platforms are listed at https://intellij-support.jetbrains.com/entries/23358108-Directories-used-by-the-IDE-to-store-settings-caches-plugins-and-logs:
OSX
Configuration:
~/Library/Preferences/<PRODUCT><VERSION>
# e.g.:
~/Library/Preferences/IntelliJIdea14
Caches:
~/Library/Caches/<PRODUCT><VERSION>
Plugins:
~/Library/Application Support/<PRODUCT><VERSION>
Logs:
~/Library/Logs/<PRODUCT><VERSION>
Linux/Unix
~/.<PRODUCT><VERSION>
Windows
Windows Vista, 7, 8:
<SYSTEM DRIVE>\Users\<USER ACCOUNT NAME>\.<PRODUCT><VERSION>
Windows XP:
<SYSTEM DRIVE>\Documents and Settings\<USER ACCOUNT NAME>\.<PRODUCT><VERSION>
Version 15 on Ubuntu:
cd ~/.IntelliJIdea15/config/plugins
rm -r <offending_plugin>
Just delete the plugin. In my MacOS, the path to the plugins folder is:
/Users/<username>/Library/Application Support/JetBrains/<your version>/plugins