What is the java.exe difference from jdk to (included) jre? - java

So, I had always thought there was no difference between the java.exe located in the jdk\bin and that in the jdk\jre\bin folders. Apparently, that is not the case, certainly not with java8 anyway.
I was testing the maverick ssh library and found that it would not auto-negotiate an encryption cipher from the list offered by the sshd server when using the java.exe from jdk\bin. Changing the java.exe used to that from the jre supplied with jdk (in the jdk\jre\bin folder) let the test app work fine.
So... what could possibly explain the difference - why would one java.exe work and the other not, if they are both the same?
They appear the same on the surface:
C:\Program Files\Java\jdk1.8.0_20>dir bin\java.exe
08/22/2014 03:35 PM 190,856 java.exe
C:\Program Files\Java\jdk1.8.0_20>dir jre\bin\java.exe
08/22/2014 03:35 PM 190,856 java.exe
But must be different under the hood:
C:\Program Files\Java\jdk1.8.0_20>diff bin\java.exe jre\bin\java.exe
Files bin\java.exe and jre\bin\java.exe differ
EDIT:
I did review the question which is suggested as a duplicate, however it did not address my question.
The versions of the binaries appear the same:
C:\Program Files\Java\jdk1.8.0_20>bin\java -version
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
C:\Program Files\Java\jdk1.8.0_20>jre\bin\java -version
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)
I did not adjust the classpath or anything else on my commandline, other than the path to java.exe.
Compared the two using WinMerge... there are a few diffs nr the start and end (moreso) of the two files. All binary gobble-de-gook to me.

Re using that library and getting different results, that's almost certainly not anything to do with java.exe, but something to do with the classpath and jars used by the JDK install vs. the JRE install.
Re your different files, it's not just you: I dug up a Windows 8.1 machine with (an old copy of) Oracle's Java8 on it, and it's the same thing: Sizes, dates, and versions match, contents don't quite. This isn't true of my Linux box with Oracle's Java8 on it, where the jdk/bin/java and jdk/jre/bin/java files are identical (and not just symlinked). My guess is it relates to optimization defaults, but doesn't relate to your ssh library issue.

Related

Eclipse(2020 09) Java Installation issue || Windows 10 OS

I am new to Java programming. I have installed Java SE 11 (LTS) (JDK 11.0.8) on my OS. Note that former Java also has jre folder in it. But Java 11 onward there come only JDK folder.
So, I have set JAVA_HOME environment variable as well as, included jdk\bin in path as well.
By checking on cmd java version shows as follow:
C:\Users\user>java -version
java version "11.0.8" 2020-07-14 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.8+10-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.8+10-LTS, mixed mode)
Then I installed eclipse 2020 09 version. But by making a simple Hello World project does not work.
And shows this error multiple times.
Description Resource Path Location TypeThe project was not built due to "Failed to init ct.sym for C:\Users\Irfan Umar\AppData\Local\Temp\eoiE758.tmp\plugins\org.eclipse.justj.openjdk.hotspot.jre.minimal.stripped.win32.x86_64_14.0.2.v20200815-0932\jre\lib\jrt-fs.jar". Fix the problem, then try refreshing this project and building it since it may be inconsistent HelloWorld Unknown Java Problem
What is the solution, I believe it is related to JRE not provided in JDK now.
Eclipse uses Java in two ways. It runs Eclipse with Java, and it allows specifying Java Runtime Environments in Preferences. I rarely see any reason to set JAVA_HOME anymore, because I specify the paths to the JDKs I want to use. I always have multiple JDKs installed.
I specify which JDK to use to run Java by setting the "-vm" path in the "eclipse.ini" file (which points to the "bin" directory).
I specify which JDK to use to compile code by adding JREs in preferences, and sometimes editing the "Execution Environments" (subsection of "Java Runtime Environments") to point to specific JREs.

can't find jconsole in directory path java

I installed Cassandra 4 on vm, then I want to use jconsole to monitor it, but I can't find the jconsole directory.
According to the documentation, it is located at /usr/lib/jvm/java-8-oracle/bin/jconsole. After I searched it was not there.
This is my java -version:
openjdk version "1.8.0_262"
OpenJDK Runtime Environment (build 1.8.0_262-b10)
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)
Can someone help me?
The documentation you're referring to is talking about Oracle Java, whereas you've installed OpenJDK. jconsole will be living in a different folder.
at the commandline, try ls -la $(which jconsole) to see where it is located. assuming the JDK installed the binaries in the "usual" places.

Eclipse (and STS) using wrong JDK to start up

I have several versions of Java on my system (OS X El Capitan, version 10.11.6). My current JAVA_HOME variable is set to a Java 8 JDK, and the bin directory is in my path:
$ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
Nevertheless, whenever I try to start Eclipse or STS, I get a crash, and inside the .metadata/.log file in the workspace it includes the line:
java.version=9-ea
I can edit the eclipse.ini file and add a -vm flag to get it to start with the proper JVM, but what mystifies me is where Eclipse is getting the wrong information in the first place. Isn't setting JAVA_HOME enough? Where else might it be finding Java?
I think the native launcher of Eclipse uses /usr/libexec/java_home to determine the current JVM to use and I am not aware of a way to change that command to point to a different VM as a default.

java -version returns different version to that as specified in PATH

My intention is to do a bit of modding of Minecraft using MCP. For that, my Java JDK needs to be specified in the system PATH and working. Unfortunately, it isn't working as typing "java -version" returns the version I use for running Minecraft (JRE7), not the one I've specified in the PATH (JDK6). (Note: JDK6 is supposedly what's needed for this, and the JRE obviously wouldn't work for development anyway.)
Here's my full PATH:
C:\Program Files\Java\jdk1.6.0_45\bin;C:\Program Files (x86)\OpenVPN\bin;C:\Program Files (x86)\Google\google_appengine\
The specified JAVA_HOME:
C:\Program Files\Java\jdk1.6.0_45
And here's the result of "java -version", even after a full system restart since installing the JDK and setting the PATH:
java version "1.7.0_45"
java(TM) SE Runtime Environment (build 1.7.0_45-b18)
java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
Help would be massively appreciated, thanks!
x_a_horse_with_no_name's comment got it! I simply renamed java.exe and javaw.exe in C:\Windows\System32 (& in \SysWOW64), thereby forcing Windows to instead read from the PATH. My guess is that the JDK6 install refused to overwrite the JRE7 files as they were newer or something. Regardless, problem solved, thanks!

Why this version of java?

On my Red Hat server, java -version outputs;
$ java -version
java version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) 64-Bit Server VM (build 20.2-b06, mixed mode)
$
However, neither PATH, nor JAVA_HOME environment variables are set. Likewise, JAVA_HOME is not set on ~/.bash* files.
Why and how my server uses this version of Java while two other versions of Java are installed as well?
Firstly, JAVA_HOME is not involved in this. (JAVA_HOME is used conventionally by wrapper scripts, etc for applications that use Java ... but not by any of the Java executables themselves.)
Second, you are probably running java via a symlink managed by the alternatives program. (RHEL and similar distros use this utility to allow you to select different versions of utilities installed on the same system.)
Either way, running the following will help you figure out what is going on.
$ ls -l `which java`
(Then following the chain of symlinks until you get to the actual executable.)
Which executable runs depends on PATH variable. Double check it. It can't run if not set it is impossible unless you have some strange Linux config.
If Java executable is in current directory, it would run by ./java. Since it runs with just java it is somewhere in the PATH.

Categories