Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switch between Java 32-bit and Java 64-bit

Tags:

java

tomcat

I have just found out that Apache Tomcat cannot run as a Windows service if I'm using a 64-bit JDK. Therefore I have additionally installed Java 32-bit on my Windows.

The question is when I checked the java version using java -version, it still shows that 64-bit is still running. How do you switch from 64-bit to 32-bit? It would also be nice to have the ability to switch back to 64-bit later as well.

like image 548
Best Avatar asked Jan 19 '23 04:01

Best


1 Answers

The question is when I checked the java version using java -version, it still shows that 64-bit is still running.

That's not strictly true. There is no copy of Java still / already running. (Or if there is, you aren't talking to it when you run java -version.)

What this actually shows is that your command shell runs a 64-bit Java when you gave it the command name java. And the reason for that is that shell's %PATH% variable is telling the shell to look in the directory containing the 64-bit version, rather than the 32-bit version; i.e. you haven't changed it!

What you need to do is to change the shell's %PATH% and %JAVA_HOME% environment variables to point to the correct place. The %JAVA_HOME% should point to the installation directory, and the %PATH% variable should include %JAVA_HOME%\bin.

like image 185
Stephen C Avatar answered Jan 28 '23 01:01

Stephen C