I have a project in IntelliJ Idea that uses jdk 8. In my system I have many jdk installed for development. Every time I create a new terminal window inside IntelliJ, the latest system jdk (jdk 10) is used and not the project one (jdk 8 in this case) and I have to switch manually. Of course I realise the error only after some build which requires jdk 8 does not work properly.
Is there a possibility to set the jdk used in IntelliJ terminal?
Check Preferences->Tools->Terminal do determine the used shell implementation.
Change the shell path or change your environment settings with the used shell to take effect e.g. for setting JAVA_HOME and PATH.
You can even use the "shell integration" flag to load a custom rc config file. Please check the IntelliJ documentation for this.
You are not able to use the configured projects JDK in a dynamic way. If you need this, please file an enhancement request to Jetbrains.
You need to change the SDK version in project structure. You can change it through IntelliJ navigation top bar, by following this path:
File > Project Structure > Project tab > Project SDK
I repost the answer of #yole from the comments. It is not possible.
For anyone else who stumbles on this question, here is how I resolved a similar issue:
Maybe this is just my company's security*, but when a JDK is installed with an .exe, something like the following path is created and added to the root of the %path% variable:
C:\Program Files\Common Files\Oracle\Java\javapath
On that path you'll find a 'java' executable for the installed version of java.
The fix was to simply uninstall that version of java, via the system settings.
* I mean that I was unable to see the 'true' path variable, may have been my company's security.
Related
Eclipse was so far using the installed jre "jre1.8.0_261". I want eclipse to use jdk. I have changed the eclipse.ini and have added the following :-
-vm
C:\Program Files\Java\jdk1.8.0_191\bin\javaw.exe
Moreover, I have changed the windows preferences with Installed JREs as the one offered by the jdk "jdk1.8.0_191". The java build path has been also aligned to use "jdk1.8.0_191" .
However under the configuration of Eclipse IDE Installation, I could still see that Eclipse is using the previously used jre version as vm.
-vm
C:\Program Files\Java\jre1.8.0_261\bin\server\jvm.dll
However, I want Eclipse only to use the mentioned JDK. Is there any solution to this?
Eclipse can use one Java distribution to run Eclipse, and any Java distribution to compile code with. It can certainly use a different distro to run than it uses to compile code. You can even have different projects using different distros.
It's probably best to have a single "-vm" option in the "eclipse.ini" file, which specifies the latest version of Java (I suppose it's possible it could just be a JRE, but I haven't tried that). Then, install the JDK of whatever version you need, and specify that in the "Installed JREs" list. Make sure that the page underneath that, "Execution Environments" maps the "JavaSE-1.8" to your installed JDK.
I have installed the JDK jdk-8u144-windows-x64.exe in my computer in order to set up the tool IntelliJ to play with Scala, well before move forward to IntelliJ installation I ensured the JDK in my computer:
running path:
the running a java version:
Then, I installed the IntelliJ and the Scala plugins, so when finally I'M going to create my first project my laptop configuration is not mapping the JDK:
I tried to add the required environment just clicking on new and go thru the path where I installed the jdk but it doesn't go thru either.
Please, guys, I'm a bit nooby with Scala and IntelliJ, could you please guide me a bit. I tried to follow the instructions in this link but it is not going thru. https://www.scala-lang.org/documentation/getting-started-intellij-track/getting-started-with-scala-in-intellij.html
thanks
Make sure you have set environment variable JAVA_HOME to your java directory, IntelliJ detects JDK using that environment variable, or you can browse the path of java installation directory using "New" button beside jdk and select it.
when I open eclipse Mars it ask for java 8(for JavaFX), and then When I did install java 8u74 now some of my older java app showing that it need java 7(my older installed version). And when I tried to keep both I found some of faculty said to not keeping both. I don't know what to do? Please Kindly help me?
When I open eclipse Now It is showing:
"You are not running your eclipse instance with Java7 or Java8. The JavaFX tooling is disabled because of this.Make Java7/8 the default system java or adjust your eclipse.ini to pass -vm pointing to your Java7/8 install."
You can try to manually change the Java library for a specific project.
Right click on the project folder, then go to:
properties->Java Build Path->Libraries->Add Library
and there add the Java 7 library.
If this doesn't work or you don't see the Java 7 library you might need to add some environment variables (e.g. JAVA_HOME)
Go to the eclipse installation folder and modify the below property in eclipse.ini file:
-Dosgi.requiredJavaVersion=1.7
Hope this helps!
I am trying to run java application and I am getting following error,
Unable to find a javac compiler; com.sun.tools.javac.Main is not on
the classpath. Perhaps JAVA_HOME does not point to the JDK
I have gone through many SO questions and found solution is JAVA_HOME should be point to JDK, not JRE.
Then I have tried to print JAVA_HOME in command prompt,
I had set this JAVA_HOME from my computer->properties->env variables -> system vars as below,
I had also added new variable in eclipse using preferences as,
And finally I am still getting the same error. Whats wrong with JAVA_HOME ?
Update :
In eclipse-preferences-installed jres there is only one entry is present and which is jdk and selected,
And under project properties java build path-libraries there is JRE System Liberary [jdk1.8.0_31] is used.
Update 1 :
C:\Program Files\Java\jdk1.8.0_31 have folder named jre. Is that jre folder causing this issue ? Can I remove this folder ? Is there is any way to add only jdk liberary in project ?
Eclipse is an IDE and as such, it has (at least) two Java versions: The one which it uses itself to run (JAVA_HOME) and a JVM which it uses to run your application. The two don't need to be the same.
So to fix your problem, you need to look into Eclipse's preferences, specifically Installed JREs which gives you a list of Java VMs which Eclipse will use to run Java code from projects. My guess is that there will be several entries there and the default will be a JRE instead of a JDK.
Make sure you have a JDK in the list and then go to your project. In the project, you can select which Java VM to use under Java Build Path -> Libraries.
[EDIT]
Look closely at the last screenshot: You've configured Eclipse to use C:\Program Files\Java\jdk1.8.0_31\jre which means you've pointed it at the JRE inside of the JDK. Use C:\Program Files\Java\jdk1.8.0_31 instead (without the \jre at the end).
[EDIT 2] If you delete the jre folder, Java will stop working. Any JDK also contains a JRE. The JRE contains rt.jar with String.class and the like. The Java compiler is in tools.jar which is in the JDK.
If recreating the JRE entry in Eclipse doesn't help, you'll have to add it manually to the classpath.
You can use a variable ("Add Variable...") to make sure Eclipse updates the path when you switch to a new/different JRE. Try JAVA_HOME with the extension lib/tools.jar
In Eclipse click Run->External Tools->External Tools Configurations
Click JRE tab
Click Installed JREs... button
Click Add button (select Standard VM, where applicable)
Click Directory Button
Browse to your JDK version (not JRE) of your installed Java (eg: C:\Program Files\Java\jdk1.7.0_04)
Click Finish.
Re-run Ant script - have fun!
I faced the same issue while i was using ant from command prompt and the solution which I found is that you need to put tools.jar inside bin folder which is present inside apache ant folder.
For eg :-
D:\apache-ant-1.10.12-bin\lib
You will get tools.jar inside
C:\Program Files\Java\jdk1.8.0_211\lib
Please change the path based on your java installation path.
I wish I could give you guys more information on what's going on, but I really have no idea. I am trying to install groovy and grails tools suite from springsource and I am having trouble configuring it to work properly. I have the most up to date JDK, and the preferences show it, but I still get warnings and it does not build. I have posted some pictures below to show what is going on.
on your GGTS go to window
select java
select installed JREs
add-> Standard VM
jRE home select directory up to C:\Program Files\Java\jdk1.6.0_18
select jdk1.6.0_18 from installed JREs
I faced a similar issue (I am sure it is the exact issue) - Here are the steps to ensure it works correctly, I struggled with initially but this got it going.
Install JDK from http://www.java.com ,in a directory where there are NO SPACES in the path
Set JAVA_HOME to your JDK installation
Ensure %JAVA_HOME%\bin; is in your PATH variable.
On the command prompt run java -version, it should give you the path where JDK is installed
Install STS Springsource Tool suite.
Run your STS and create a new grails project and run it.
Let me know if that does not work.
It might be that you are launching Eclipse with a JRE even though you have a JDK installed as one of the compilers in your workspace. To find out if you are launching with a JRE or JDK, go to Help -> About GGTS -> Installation details -> Configuration
Look for the -vm option and make sure it is a JDK not a JRE.