How to specify an alternate JRE?

A

antonyliu2002

The Windows XP work station I use in my lab does not have J2SE
installed. It only has the JRE of version. 1.4.2_08 installed. Look:

C:\Documents and Settings\antonyliu>java -version
java version "1.4.2_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)

C:\Documents and Settings\antonyliu>

I don't wanna go through the hassle to ask the administrator of my
windows work station to install the newest J2SE package. So, I
installed JDK1.5 under my home directory C:\Documents and
Settings\antonyliu\jdk1.5

I've set the PATH, CLASSPATH and JAVA_HOME to point to this jdk1.5
folder. Look:

PATH=%PATH%;C:\Documents and Settings\antonyliu\jdk1.5\bin
CLASSPATH=%CLASSPATH%;C:\Documents and Settings\antonyliu\jdk1.5\lib
JAVA_HOME=C:\Documents and Settings\antonyliu\jdk1.5

But whenever I run java -version, it still shows me the old one. So,
is it possible to specify a JRE different from the system default?

Thanks.
 
A

Andrew Thompson

The Windows XP work station I use in my lab does not have J2SE
installed. It only has the JRE of version. 1.4.2_08 installed. ... .....
I don't wanna go through the hassle to ask the administrator of my
windows work station to install the newest J2SE package.

Administering the system is the *job* of the Sys. Admin.,
and they are likely to take regular measures to ensure the
workstations under their care are cleared of 'unauthorised'
applications - most simply by reinstalling the 'base' system
afresh.

(My advice) Stop trying to fight them, but instead convince
them of the necessity of keeping Java up to date.

Andrew T.
 
M

Manish Pandit

Most probably, your existing path (%PATH%) has the 1.4 release - that
could be why your version is not being picked. Assuming you can change
the path, put the path to 1.5 JDK before %PATH% and see if that works.

Another thing - If you are using something like eclipse for your java
development, you can configure it to point to 1.5 release, and it will
pick everything up from there. As long as you are writing, compiling
and running the java code within eclipse, you would not have to worry
about setting paths. I believe other IDEs have something similar as
well.

-cheers,
Manish
 
T

Thomas Kellerer

The Windows XP work station I use in my lab does not have J2SE
installed. It only has the JRE of version. 1.4.2_08 installed. Look:
[...]

I've set the PATH, CLASSPATH and JAVA_HOME to point to this jdk1.5
folder. Look:

PATH=%PATH%;C:\Documents and Settings\antonyliu\jdk1.5\bin
CLASSPATH=%CLASSPATH%;C:\Documents and Settings\antonyliu\jdk1.5\lib
JAVA_HOME=C:\Documents and Settings\antonyliu\jdk1.5

But whenever I run java -version, it still shows me the old one. So,
is it possible to specify a JRE different from the system default?

When the JRE is installed, it puts a version of java.exe and javaw.exe into
c:\Windows\System32
I guess that's the one beeing executed. You have three choices: either delete
those two files, but I doubt that you have the necessary user rights for that.

Change your path definition to include your homepath _before_ the regular PATH
varaible (PATH=C:\Documents and Settings\antonyliu\jdk1.5\bin;%PATH%)

Simply call "your" java.exe directly by specifying it's location.

Btw: I would not set the CLASSPATH, this is usually not necessary nowadays. That
should be handled when calling your app with the -cp switch

Thoams
 
B

Brandon McCombs

The Windows XP work station I use in my lab does not have J2SE
installed. It only has the JRE of version. 1.4.2_08 installed. Look:

C:\Documents and Settings\antonyliu>java -version
java version "1.4.2_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)

C:\Documents and Settings\antonyliu>

I don't wanna go through the hassle to ask the administrator of my
windows work station to install the newest J2SE package. So, I
installed JDK1.5 under my home directory C:\Documents and
Settings\antonyliu\jdk1.5

I've set the PATH, CLASSPATH and JAVA_HOME to point to this jdk1.5
folder. Look:

PATH=%PATH%;C:\Documents and Settings\antonyliu\jdk1.5\bin
CLASSPATH=%CLASSPATH%;C:\Documents and Settings\antonyliu\jdk1.5\lib
JAVA_HOME=C:\Documents and Settings\antonyliu\jdk1.5

But whenever I run java -version, it still shows me the old one. So,
is it possible to specify a JRE different from the system default?

Thanks.

The OS is finding java in the first place it can which is in the 1.4
directory. If you place the 1.5 directory in front of the existing 1.4
location in the path then it will be found first and thus be used.
PATH=C:\Documents and Settings\antonyliu\jdk1.5\bin;%PATH%
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,709
Latest member
AustinMudi

Latest Threads

Top