JRE and JDK Paths - java

I am currently learning coding and Java. I have done lots of research on this topic but I just can't seem to understand it. So I have the JDK 9.0.1 and JRE 9.0.1. As you can see here I have the JRE and JDK 9.0.1 in my Programs and Files folder in my C drive/ SSD:
I am trying to figure out how to add both the JRE and JDK to the Environment Variables. I have tried numerous things but sometimes I can only get one or the other to work (i.e. java working in CMD but not javac). This is currently what my variable looks like.
I have tried doing the semicolon then put my other JDK bin folder path but it didn't work. Any suggestions?

Assuming you intended to ask about "Java" as opposed to "javascript", there is no need to have both the jdk and the jre. The jdk contains the jre.

Related

Cannot add java 11 jre in STS version 4.5.0

I am trying to migrate my Springboot projects from Java 8 to Java 11 although I'm having issues first on updating the installed jre of my STS. Since java 11 doesn't have any separate jre, unlike the previous versions, I was trying to include the jdk 11. Although as you can see on the bottom photo, it does not seem to locate the jrt-fs.jar file.
I've also tried to configure the SpringToolSuite4.ini file by including these lines:
-vm
C:\Program Files\Java\jdk-11.0.7\bin\javaw.exe
This is how my .ini file looks like:
Although nothing still happens. Anyone who has other pieces of advice on where I should check? Thank you in advance!
In the preference for configuring the JREs you should select the JDK folder itself, not the lib nor the bin folder. Eclipse will find all the necessary files and libraries that are included in that JDK and can deal with JDKs >= 11.
Please note that this preference is different from the VM that you specify in your ini file. The VM in the ini file is used to run the IDE itself, not to compile your projects against or run them. It is a totally separate thing, which allows you to run your IDE on JDK11 (for example), whereas at the same time you can implement and run projects on JDK8 or JDK14 (or whatever).
You are adding the lib/ dir instead of bin/.
Don't forget to add bin/ to the %Path% environment variable.
Make sure you don't have duplicates from earlier versions of the jdk/jre.
Sorry, you are adding the jdk instead of the jre that is expected:
https://www.java.com/de/download/help/download_options.xml

Does java use the registry to locate its default jar files?

Target Environment
Windows 7 (6.1)
Java 1.8.0_121 64bit
I recently created a minimal java environment consisting of just the single file java.exe in a newly created, empty directory and successfully ran a simple HelloWorld.class file simply by copying it to the same directory and typing:
.\java HelloWorld
I found this kind of surprising, and wondered if maybe because the version of java I was using (jre 1.8.0_72) had been installed from an .exe file whether there was something in the Windows registry telling java.exe where to find rt.jar and such.
Running the java control panel, you can certainly see java 1.8.0_72 is in there:
I if I used a java version which was NOT installed (i.e. a standalone java version) would I get a different result?
Well, before trying a stand-alone version I think I'll try a computer having NO java on it at all. Same exact set up as before.
Found part of the answer on my wife's Windows 10 computer (which has no java on it):
Clearly, I should copy java.dll somewhere. Think I'll put it in the same directory as everything else (i.e. the same one as the java.exe), and try that.
Nope. Same as before.
So clearly java is looking in the registry to find its .dll.
I've downloaded jre-8u121-windows-x64.tar.gz. I'm going to try the same experiment with that.
Tried the same experiment with java from the tarball above. Exact same symptom. Cannot find java.dll.
Having done a little reading, I see that Embedded Java SE has a way to create custom deployments of java. There appears to be no official analogous mechanism for Java SE for Windows.
Doing a little more reading, I see that there is a mechanism called the Invocation API which can be used to run java, bypassing java.exe. This might be something to try. Might also be time to start surfing the HOTSPOT code.
More on the Invocation API here: http://docs.oracle.com/javase/6/docs/technotes/guides/jni/spec/invocation.html
An intriguing note I also ran into during my reading said this:
Private vs. public JRE - Installing the JDK installs a private Java SE Runtime Environment (JRE) and optionally a public copy. The private JRE is required to run the tools included with the JDK. It has no registry settings and is contained entirely in a jre directory (typically at C:\Program Files\jdk1.6.0\jre) whose location is known only to the JDK.
I read this here: http://www.oracle.com/technetwork/java/javase/install-windows-142126.html
You might try this experiment with THAT jre.
Today I also face same problem .and I found the solution for this go-to your JDK bin copy path from there and peast this path to environment variable path and the priority should be first that mean it should be peast in starting of all path.

Eclipse not working after deleting a version of java

I found out I had the JRE and the JDK on 2 different folders, I then deleted the JRE. The JRE is still here in the JDK install.
I then searched a bit about the problem. I created the environment variable (I am on W10) JAVA_PATH with the good path but it still doesn't work.
A dialog box says (I can't copy paste all) :
JVM terminated
C:\ProgramData\Oracle\Java\javapath\javaw.exe
(lots of things)
I don't know how to get it working.
Reinstalling your JRE will solve the problem. If you want to get rid of some software always deinstall it if possible because you don't know where all of the files and settings were installed.
you will need java, if you have a JDK the a JRE is included there by default..., maybe you had 2 version of java and you still have a jdk, so lets say you deleted the jre, then you need to tell the eclipse IDE that it must use the version you have installed and where it can find it..
How:
like this...
but now, if you deleted ALL the java versions then you will need to install at least one...
You should have defined your environment variable as JAVA_HOME and assign it your JDK's path. Then, add this variable to your PATH variable as JAVA_HOME/bin.

JDK for Eclipse(in windows platform)

My qustion is really simple, all in the title.
After some tests I found that by given a JRE/bin directory in the path(environment variable) , Eclipse can run normally with no problem. And Eclipse will never try to find the JRE by using JAVA_HOME variable.
And in eclipse, I know that I can add installed JREs in the window preference and choose a JDK folder instead of a JRE folder. And for each project, we can change the compiler level.
Since Eclipse can also compile the codes, when is JDK used? Debug? or what?
Eclipse uses its own compiler to compile Java code. It is different than the javac compiler that comes with a JDK. In fact, you don't need a JDK to compile and run normal Java projects in Eclipse. A JRE is obviously needed to reference the required Java libraries.
However if you are using Maven or some other tools that sometimes depend on a JDK component, then you need to install a JDK on your machine. For example, Maven has an option to rely on the tools.jar that comes shipped with a JDK.
Eclipse uses the JRE you specified as default or per project settings. This could be a (only) JRE installation or a JRE from a JDK installation.
I think the more interesting question is: When should I use a JDK instead of an JRE?
The JDK includes tool that are not included in the standalone JRE. E.g. the javadoc.exe for exporting the documentation from javadoc annotated comments in the code. This Program is not included in a standalone JRE. so if you want to export your javadoc documentation you need to add an installed JRE based on a JDK installation first, so Eclipse is able to use the javadoc tool.
It could be a little hard to give a thorough answer to this but I know that at least for using Maven/m2e Eclipse needs to be run in a JDK.
First of all eclipse is a java code it wouldn't run without java installed to prove it (on your personal expence) copy the eclipse folder elsewhere and uninstal the JDK and try to run jave it wouldn't it would output the error message no JDK but instal JDK and run eclipse from the copied location it would run as a first time asking you about the workplace directory!.

Android SDK and Java

Android SDK Manager complains "WARNING: Java not found in your path".
Instead of using the information from Windows registry, the software tries to search Java in the default installation folders, and fails (I don't install software in program files because I don't like space characters in my paths). Of course I know how to modify the %PATH% environment variable. The question is — which Java does it need?
After installing the latest JDK, I’ve got 4 distinct versions of java.exe file, in the following 4 folders: system32, jre6\bin, jdk1.6.0_26\bin, and jdk1.6.0_26\jre\bin. Size ranges from 145184 to 171808. All of them print version “1.6.0_26” when launched with the “-version” argument. The one in system32 has .exe version “6.0.250.6”, the rest of them is “6.0.260.3”. All 4 files are different (I’ve calculated the MD5 checksums).
Q1. Which folder should I add to %PATH% to make the Android SDK happy?
Q2. Why does Oracle build that many variants of java.exe of the same version for the same platform?
Thanks in advance!
P.S. I'm using Windows 7 SP1 x64 home premium, and downloaded the 64-bit version of JDK, jdk-6u26-windows-x64.exe.
jre6\bin should work. That's what I put in %PATH%.
JRE is the Java Runtime Environmen and JDK is the Java Development Kit).
jre6\bin comes from JRE.
jdk1.6.0_26\bin has the development kit binary files
jdk1.6.0_26\jre\bin has an implementation of the Java Runtime Environment for use by the JDK
Please see Contents of the JDK for more info
Try setting JAVA_HOME pointing to the jdk1.6.0_26 directory. See this post.
Actually I got stuck in this same problem, and although that the above answer should work properly... it didn't work for me.
The only solution that fixed this problem for me is copying the installed jdk folder to folder C:\Program Files\ ... and name that folder Java!
I know that this doesn't make any sense! but that what solved my problem after it make me go crazy.
I hope the normal solutions would help your problem, otherwise; you might think of my ugly solution and I hope your problem gets fixed soon.
Thanks,
Mohamed A.Karim.
What helped me was changing one of Enviroment Variables (right-click on "my computer" then "Advanced system settings" or similar) named PATH. Using function "edit" i added this:
C:\Program Files\Java;C:\Program Files\Java\;C:\Program
Files\Java\jdk1.6.0_29;C:\Program Files\Java\jdk1.6.0_29\;C:\Program
Files\Java\jdk1.6.0_29\bin;C:\Program Files\Java\jdk1.6.0_29\bin\
(one of those is sufficient, but I don't know which).
I have Windows Vista 32bit.
replace "program files' with "progra~1" in your path
I have the same problem, maybe because I installed JDK on E: instead of C:
Solved by creating a run.bat file with these:
set JAVA_HOME="E:\Program Files\Java\jdk1.6.0_26"
set PATH=%PATH%;"E:\Program Files\Java\jdk1.6.0_26\bin"
call "sdk manager.exe"
Works perfectly
Perhaps the path did what I needed

Categories