Fandom

How To Wiki

Howto use a custom JDK and JRE

1,795pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

JDK is related to Java compiling and debugging and JRE is only used only to run pre-compiled Java software. Sometimes you have the latest JDK6 beta installed but some applications only run in JDK5 or the old JDK4 (for old versions it was called SDK). This howto explains how you can use a secondary java without actually installing it by default on your system.

This also works if you don't have any java installed and you don't want or you don't have administrator privileges to install one by default. Note that if you are not root, you will have to install it in your home directory, not in '/opt/.

In Linux and Unix-like systems Edit

First uncompress a complete JDK (old SDK) in /opt/javaX directory, where X is the version number.

Then, you will have to modify the PATH variable, and put first your custom java directory. Then, you should chage JAVA_HOME environment variable and CLASSPATH also.

For example if you are using bash and your JDK/JRE is placed in /opt/java5, you can type:

export PATH="/opt/java5/bin/:/opt/java5/jre/bin/:$PATH"
export JAVA_HOME="/opt/java5"
export CLASSPATH=":/opt/java5/lib:/opt/java5/jre/lib"

For the CLASSPATH, you can type "echo $CLASSPATH" first to ensure you have no other directory into your classhpath.

In a terminal Edit

If you are in a terminal and want to have such an environment, you can simply create a script java5_env.sh that contains:

 
export PATH="/opt/java5/bin/:/opt/java5/jre/bin/:$PATH" && export JAVA_HOME="/opt/java5" && export CLASSPATH=":/opt/java5/lib:/opt/java5/jre/lib" && bash

Running an application Edit

To run an application requiring some other java version than the one installed you can use a script like this (supposing your application is called azureus, your script will be azureus_launcher.sh):

export PATH="/opt/java5/bin/:/opt/java5/jre/bin/:$PATH" && export JAVA_HOME="/opt/java5" && export CLASSPATH=":/opt/java5/lib:/opt/java5/jre/lib" && azureus
ssss From HowTo Wiki, a Wikia wiki.

Also on Fandom

Random Wiki