can't find JRE in the JDK - jvm

i install JDK in
C:\Program Files\Java\jdk1.6.0_24
and set the variables as follow:
JAVA_HOME: C:\Program Files\Java\jdk1.6.0_24
CLASSPATH: .;C:\Program Files\Java\jdk1.6.0_24\lib;C:\Program
Files\Java\jdk1.6.0_24\lib\tools.jar;
PATH: C:\Program Files\Java\jdk1.6.0_24\bin
but when i run the java -version command , the error
could not open `C:\Program Files\Java\jre6\lib\i386\jvm.cfg'
comes up. then i move the jre folder out the jdk folder to
C:\Program Files\Java\
and change the folder name to jre6 (then it has the C:\Program Files\Java\jre6 folder) , everything becomes good then .
why this is happening ? it seems to me that it is not the environment variables that are controlling the JVM's location.

If it is not the path that is controlling the location of the JRE it must be the registry:
http://java.sun.com/j2se/1.3/runtime_win32.html.

On Windows 64 bit OS check also:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment

I set my
JAVA_HOME: C:\Program Files\Java\jdk-14.0.2
worked fine for me.

Related

Missing tools.jar when launching STS application

I have the latest STS4. I am using installed java-1.8 JDK not embedded as the execution environment. My project just runs fine without any issue.
However when I launch the STS application itself I have a pop up saying
"Missing tools.jar"
I have already tried:
pointing JAVA_HOME to different JDK
added -vm args in the .ini file.
Yet I cannot get rid of this pop up.
I solved this same problem by modifying the file "eclipse.ini". First I tried to solve it by modifying the file SpringToolSuite4.ini, but nothing happened, because I previusly had installed the eclipse ide, and the change in SpringToolSuite4.ini didn't work. then I modified the file eclipse.ini; and it worked.
The changes that I did in eclipse.ini are detailed below:
To check with what Java version (JRE or JDK) Eclipse is running, do the following:
Open the menu item Help > About Eclipse. (On the Mac, it’s in the Eclipse-menu, not the Help-menu)
Click on Installation Details.
Switch to the tab Configuration
Search for a line that starts with -vm. The line following it shows which Java binary is used.
Depending on the name and location of the used Java binary one can figure out if a JRE or a JDK is used:
If the path contains “jre” (e.g. as in C:\Program Files\Java\jre6\bin\client\jvm.dll) it is a JRE
If the path contains “jdk” (e.g. as in C:\Program Files\Java\jdk1.6.0_31\bin\javaw.exe) it is a JDK.
If no JDK is used for Eclipse, change it:
Quit Eclipse if it is running
Go to the Eclipse installation directory and open the file eclipse.ini in a text editor.
Search for the line -vmargs
Before the line -vmargs, add two lines:
On the first line, write -vm
On the second line, write the path to your JDK installation (usually something like: C:\Program Files\Java\jdk1.6.0_31\bin\javaw.exe on Windows)*
source: https://matsim.org/docs/devguide/eclipse/jdk
The fix is in the -vm parameter. the order and the absolute path of the javaw.exe seems to be the issue.
the readme file mentions _
"To run Eclipse with an alternate Java runtime environment, the path to the Java virtual machine's binary must be identified. With an Eclipse installation from the distribution, altering the $PATH variable to include the path to the alternate Java runtime environment is often not enough as the Eclipse that Linux distributions package often performs a scan internally to pick up GCJ by itself whilst ignoring what's on the $PATH."
So I have edited now the SpringToolSuite4.ini and made this entry
-vm
C:\UserTemp\Softwares\java\jdk\oracle-jdk-1.8-64bit\bin\javaw.exe
Restarted my STS and it works perfect.
The reference to set the JVM Specifying the JVM was very useful in understanding this.
Don't spend too much time looking for tools.jar. If you get an error like that, don't be upset.
If you already have java JDK1.8, go to its lib folder, tools.jar should be available there. Copy and paste the same in JRE1.8 lib folder.
I have STS4 so I have modified SpringToolSuite4.ini
I changed from:
[...]
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.8
[...]
to exactly this
[...]
--launcher.defaultAction
openFile
-vm
C:\Program Files\Java\jdk1.8.0_152\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.8
[...]
And the message dissapeared
SOLUTION :
Check your Path JAVA_HOME - system property "Environment Variables"
for example: JAVA_HOME:
C:\Program Files\Java\jdk-12.0.1\lib
usually you only need add \lib at JAVA_HOME
Just remove this line from variable "Path"
"C:\Program Files (x86)\Common Files\Oracle\Java\javapath"
System Properties > Advanced > Environment Variables > Path > Edit > Reboot
Worked for me
In my case I had installed jre, and not jdk!
Observe that you have jdk installed!
I had the same issue when i upgraded to Java 11.
I simply edited SpringToolSuite4.ini and added
-vm
C:\Program Files\Java\jdk-11.0.4\bin\javaw.exe
For me, I had to do two things to make it work:
Remove vmargs:
vmargs
Dosgi.requiredJavaVersion=1.8
Setting the JDK:
vm
C:\Program Files\Java\jdk1.8.0_131\bin
By downloading the tool file and paste it in the jre\lib path. but make sure you should rename the pasted file as "tools.jar".
step 1
download the tool file.
download link http://www.java2s.com/Code/Jar/t/Downloadtools160jar.htm
step 2
extract the zip file.
step 3
you should rename the included .jar file as "tools".
step 4
then copy the renamed tools.jar file and paste in the C:\Program Files\Java\jre8\lib\ path.
then restart the STS ide.
I have fixed this from Window->preferences->Java->Installed JREs .
Then add the jdk bin path, uncheck other related jre paths
Copy JDK directory to your STS installation or extraction library and and rename JDK to jre. the directory structure of STS should look like this
.eclipseproduct
artifacts.xml
configuration
dropins
eclipsec.exe
features
jre
license.txt
META-INF
open-source-licenses.txt
p2
plugins
readme
SpringToolSuite4.exe
SpringToolSuite4.ini
Once STS open, initially its looking for tools.jar in jre\lib folder its not available in jre\lib folder.
so we need copy the tools.jar from jdk\lib folder and paste in jre\lib folder.
restart the STS, issue will resolve.

Error:java: Cannot run program CreateProcess error=2, The system cannot find the file specified

Error:java: Cannot run program "C:/Program Files/Java/jdk1.7.0_45/bin/java" (in directory "C:\Users\navya.chamidisetty\.IntelliJIdea2017.3\system\compile-server"):
CreateProcess error=2,
The system cannot find the file specified
I have started using IntelliJ 17 recently. When I checkout all my code in a folder and C:\ and loaded in Intellij. Now when I try to build, I am getting the above mentioned error. Could someone please help me how to solve this.
My %JAVA_HOME% = C:\Program Files\Java\jdk1.8.0_151
Value of Path variable in Environment variables = C:\Program Files\Apache Software Foundation\apache-maven-3.0.3\bin;C:\newcorpweb\cxf\bin
Value of Path variable in System variable = C:\Program Files\Java\jdk1.8.0_151\
IDEA doesn't necessary use JAVA_HOME variable. The project SDK (JDK in your case) is setup in the project settings: File -> Project Structure, Project SDK and set up the proper path there.
I have the same issue on NixOS with IntelliJ 2020.2. If I choose evident File -> Project structure -> SDKs -> + -> Download JDK, Idea does not see this downloaded JDK (error=2 etc.). But if I install and choose a system openjdk (located at /nix-store/...-openjdk-.../), everything works.
Using Open JDK by Red Hat solved my problem!
Link for the JDK
Open JDK by Red Hat

Anypoint Studio Exit Code=13

I noticed that the jre folder inside the Program Files is empty may be because of the some software update.
so had to download the jre, unzip it and then place it inside the same path as mentioned in the AnypointStudio.ini
-startup plugins/org.eclipse.equinox.launcher_1.3.100.v20150511-1540.jar
--launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.300.v20150602-1417
-vm C:\Program Files\Java\jre1.8.0_121\bin\javaw.exe
-vmargs
-Xms512m
-Xmx1024m
-XX:MaxPermSize=512m
-Dosgi.instance.area.default=#user.home/AnypointStudio/workspace
-Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2
This maybe a 64-bit vs 32-bit issue. Please verify that both JRE and AnypointStudio are belongs to same bit version.
Please check this thread for similar issue.
This post from the Mulesoft site resolve my issue with this error. If you have multiple Java executables in your Path and the executable you add for the JDK needed for Mulesoft Anypoint Studio is not the first Java executable in your path, you will get this Exit Code = 13 error. Moving the new executable to the beginning of my path fixed the issue and Anypoint now runs.
https://www.mulesoft.org/jira/browse/MULE-13717?attachmentViewMode=list

Set path to look for java.exe in the intellij codename plugin

I just install Codename plugin in Intellij and just about to start learning the tool. Have the following error message upon creating a new codename project in Intellij:
Error opening resource editor: Cannot run program "C:\Program Files (x86)\Android\android-sdk\bin\java.exe" (in directory "C:\Program Files (x86)\Android\android-sdk\bin"): CreateProcess error=267, The directory name is invalid
java.io.IOException: Cannot run program "C:\Program Files (x86)\Android\android-sdk\bin\java.exe" (in directory "C:\Program Files (x86)\Android\android-sdk\bin"): CreateProcess error=267, The directory name is invalid
The plugin should not look for java.exe inside android-sdk folder. I have set the JAVA_HOME environment variable to the proper JDK path. This only happen in Codename plug-in.
Been searching SO for answer, but to no avail. Looking to tweak around the plugin way of finding java.exe.
OS: Windows 10, Intellij version: 2016.1.1
Are you using the 3.3 or higher version of the plugin?
Notice that Android studio isn't a supported platform only IntelliJ IDEA itself.
I'd like to know more about how you were able to create that state but the fix should be simple:
Right click the project and select "Open Module Settings"
Make sure the SDK selected is a Java SDK, JDK 8 is assumed

Directory used in Command line to Compile&Run .java file

I installed JDK on my PC running windows XP, the default directory of JDK is :
C:\Program Files\Java\jdk1.7.0_05\bin
I'm following the tutorial to do a sample
My source file named HelloWorld is in another directory : E:\NotePad\Code
As the tutorial says : "To compile your source file, change your current directory to the directory where your file is located" , so I change my Command's current directory to E:\NotePad\Code , but here comes the problem which is saying 'javac' is not recognized as an internal or external command
Well, the tutorial has a solution to this problem, it seems that I should change Command Line's current directory to where the JDK is installed which is : C:\Program Files\Java\jdk1.7.0_05\bin
After I finish it, I try this commond : javac HelloWorld.java to compile the file, but it says
javac : cannot find file : HelloWorld.java
It means that the HelloWorld.java file in E:\NotePad\Code can't be compiled by the JDK which is installed in C:\Program Files\Java\jdk1.7.0_05\bin
I try putting the HelloWorld.java file in C:\Program Files\Java\jdk1.7.0_05\bin , it works fine
So the question is : How can I Compile&Run a file with the JDK installed in a different directory ?
You will either need C:\Program Files\Java\jdk1.7.0_05\bin on your PATH, or reference the compiler directly using
C:\Program Files\Java\jdk1.7.0_05\bin\javac
It sounds like you need to update your PATH variable, see here: http://docs.oracle.com/javase/7/docs/webnotes/install/windows/jdk-installation-windows.html#path