I'm having a problem with determining what version of java am I using:)
cmd.exe is using java.exe from C:\WINDOWS\system32 as specified in Path environment variable.
C:\WINDOWS\system32>java.exe -version
java version "1.6.0_17"
Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
Java HotSpot(TM) Client VM (build 14.3-b01, mixed mode)
But in windows when I right-click on that file and select Properties->Version->Full Version it says 1.6.0_22-b04.
Why?
This means you have two installations. Check your c:\program files\Java folder. Also check your PATH environment variable - it should point to the correct path.
Change to a directory which is not in your PATH environment variable and run java -version. Note that the current directory always is the first entry in PATH.
Related
I am trying to package a jar file into an executable file using the jpackage tool in Java, but the command is not recognized in the command prompt using Windows 10 and Java version:
> java --version
java 17.0.1 2021-10-19 LTS
Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)
I have the full JDK installed and the command javac is recognized.
I checked my computer with the "where java javac jpackage" command and it only found the first two in the CommonFiles folder.
I looked in the folder path "ProgramFiles\Java\jdk-17.0.1\jmods" and both the "jdk.jlink.jmod" and "jdk.jpackage.jmod" files are present.
Can someone please help me figure out why the tool isn't recognized by Windows?
I found the issue to be the way my Environment Variables were set up for Java. To fix my problem, I went into the JAVA_HOME variable and changed the entry from
C:\ProgramFiles\Java\jdk-17.0.1\lib
to
C:\ProgramFiles\Java\jdk-17.0.1
Next I updated the path variable to include "%JAVA_HOME%\bin". Before I had it listed as C:\ProgramFiles\Java\jdk-17.0.1\bin. Both of these changes were made under the System variables using the "Edit" button. I want to thank dave_thompson_085 for pointing me in the right direction.
I had Java SE (version 8) installed on my computer (Windows 10). Now, I have downloaded version 13. I have also added the path
C:\Program Files\Java\jdk-13.0.1\bin
in Environment Variables -> System Variables -> Path
But still when I write
java -version
on cmd, I get the path of the older version.
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
Upon writing
where java
I got the following result
C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe
C:\ProgramData\Oracle\Java\javapath\java.exe
C:\Program Files\Java\jdk-13.0.1\bin\java.exe
In the environment variables ->
I get the following relevant paths:
C:\ProgramData\Oracle\Java\javapath
C:\Program Files\Java\jdk-13.0.1\bin
Note: doesn't have the path of Java 8 as I deleted it.
Interestingly, I am still able to run the Java code.
I am confused now..
Move C:\Program Files\Java\jdk-13.0.1\bin to the top in the list of environment variables. Then, open a new command prompt and execute java -version.
If you don’t explicitly add the directory to your PATH environment variable, you get the java binary installed at system level.
This was typically done by the browser java plugin installer, which is not used anymore so you get to keep the old version. I would suggest uninstalling it.
I am using Mac os Sierra 10.12.3 ,I want to execute the byte code on the Java(TM) Virtual Machine
(JVM) I need to set the CLASSPATH,
Using my terminal
CLASSPATH=</Users/.../Documents/jj2000/jj2000-4.1\ 3>/jj2000-4.1.jar:$CLASSPATH export CLASSPATH
show me
-bash: /jj2000-4.1.jar:: Permission denied
I am confusing with command line how can I set the CLASSPATH.
My java is
java version "1.8.0_20-ea"
Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b20)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b20, mixed mode)
Please help.
Don't, ever, set a global CLASSPATH environment variable. Pass the classpath to each java program you launch: each one has its own, specific classpath.
java -cp /path/to/jj2000-4.1.jar:your-application.jar com.yourcompany.youapp.Main
I am installing SUbversion Edge under CentOS 7.
The first step is
Set the JAVA_HOME environment variable, and point it to your Java 6 JRE
home. For example:
export JAVA_HOME=/usr/java/default
Test the variable:
$ $JAVA_HOME/bin/java -version
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)
The problem is that /usr/java forlder not exists.
But /usr/bin/java is existing.
Have I use this folder instead?
So what do I have to do?
You should use correct Java home path in your system. If you installed Java in CentOS via YUM, then correct path should be
export JAVA_HOME=/usr/lib/jvm/jre
You should not use /usr/bin/java as JAVA_HOME, because it is not Java home path, it is symlink to java executable.
I setup Java 6 to be used by all other application. Normal setup with JAVA_HOME, JRE_HOME, etc. This is working fine.
I have another application that needs Java 7. I downloaded Java 7.exe and extraced tools.zip from it to a folder. Now I am trying to check the version going to the bin folder. When I type in java -version, I get the following error.
error occurred during initialization of vm
java/lang/noclassdeffounderror java/lang/object
where as java -fullversion shows Java 7. It looks like even though I am in the bin folder where Java.exe exists, it still getting the one from PATH?!?!
How do I use the java.exe from a folder ignoring the one from PATH?
You need much more than java to run java. You need all the rt.jar and lib which come with Java. It sounds like you are missing some part of the JRE or it can't find your JRE.
I suggest you re-install the version you need and run it using the full path name like
c:\>"c:\Program Files\Java\jdk1.7.0_60\bin\java" -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
c:\>"c:\Program Files\Java\jdk1.8.0_45\bin\java" -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
By using the full path name you can use any specific version from any directory.