Java home doesnt match java -version
Hi,
I have come across something strange. I work on 2 projects one uses java 1.4.2 and the other uses java 1.5. When switching between projects i just change the java_home environment variable however i have changed java home to 1.4.2 and notice that java -varsion still prints out 1.5. There is an issue now starting the server and i feel this could be the cause. See below. Anyone got any ideas how this could be?
Z:\>java -version
java version "1.5.0_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode)
Z:\>echo %JAVA_HOME%
C:\j2sdk1.4.2_04
JAVA_HOME isn't used to find the java executable when you just type java on the command line. Only PATH is. Other apps--ant, your IDE, tomcat, etc.--might use JAVA_HOME to find Java.
jverda at 2007-7-10 11:30:03 >

You should also change the PATH variable; the JAVA_HOME variablemeans something to just a couple of other applications; the PATHvariable however lists all directories where your shell/cmd/os shouldlook for executable binaries.kind regards,Jos
JosAHa at 2007-7-10 11:30:03 >

Here is my path environment variable:
Z:\>echo %PATH%
C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ant\bin;C:\PROGRA~1\ULTRAE~1;C:\usr\bin;C:\Program Files\jakarta-tomcat\bin;C:\j2sdk1.4.2_04\bin
I dont see what i'm missing from this. Is there something i should add or change?
Cheers,
Joe.
If you are running Java through a browser using the Java Plugin to run applets, then the Java 5 plugin willALWAYS...run as the IE plugin.There is no other way to get around it.
No im not using applets in the application. I'm getting a class loading error when i start up tomcat. It's complaining that it cant find a file. I think its something to do with this conflict in java versions...
> Here is my path environment variable:
>
> Z:\>echo %PATH%
> C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbe
> m;C:\Program
> Files\ant\bin;C:\PROGRA~1\ULTRAE~1;C:\usr\bin;C:\Progr
> am Files\jakarta-tomcat\bin;C:\j2sdk1.4.2_04\bin
>
> I dont see what i'm missing from this. Is there
> something i should add or change?
>
Look in your C:\WINDOWS\system32. You'll probably find a java.exe for version 1.5 in there. Since that entry appears before C:\j2sdk1.4.2_04\bin in your PATH, that one will be picked up before the 1.4 version.
When you install a JRE, it puts copies of java.exe and javaw.exe in C:\Windows\System32. If you want the JDK's version of the executables to be used instead, they have to appear before the System32 folder in the PATH variable. What I do is use JAVA_HOME in the PATH variable, so when I change JDK versions I only have to change it in one place: JAVA_HOME=D:\Java\jdk1.6.0
PATH="%JAVA_HOME%\bin;C:\Windows\System32;etc... That's how it looks if you do it on the command line, but of course, I actually do this through the Control Panel.
Myself I would just work with batch files that have exactly the env variables that I want (all of them.)Of course with newer windows one could also use virtual PCs and set up a virtual enviroment for each JRE. Certainly more work though.
Yes thats exactly it. thank you very much. I changed the order of my environment variables to put JAVA_HOME first. Cheers,Joe
I'm still getting my class loading problem :-( So it wasnt the issue with the java -version java_home not being set up correctly that was causing it but at least i've that sorted and ruled out. Any ideas what would cause a class not to be loaded in time to be found...
java.lang.ClassNotFoundException: com/company/threeN21/ui/user/UserGroupPermission
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
The .class file does exist in the right location in the jar. I even tried putting this class in tomcat common lib but still didnt find it.
Try putting putting the JAR in the JRE lib/ext folder.It will always find it in the classpath if you place it there.
> I'm still getting my class loading problem :-( So it
> wasnt the issue with the java -version java_home not
> being set up correctly that was causing it but at
> least i've that sorted and ruled out. Any ideas what
> would cause a class not to be loaded in time to be
> found...
"in time to be found"? Classes are loaded on demand.
> java.lang.ClassNotFoundException:
> com/company/threeN21/ui/user/UserGroupPermission
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:141)
>
Wrong class loader.