Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use ArchLinux, and an IDE called PyCharm. On its download page, it recommends using Java 6 instead of OpenJDK. ArchLinux has an OpenJDK package (jdk7-openjdk) that I have installed, installed, and from what I had read in the Arch Wiki on Java, it should be possible to install Oracle Java 6 along side OpenJDK 7 via a packages called jdk6-compat and jre6-compat, which install these versions of Java in /opt/ instead of the normal location.

However, after installing jdk6-compat and jre6-compat, I still see that I am running OpenJDK 7 when I run the following:

% java -version
java version "1.7.0_09"
OpenJDK Runtime Environment (IcedTea7 2.3.3) (ArchLinux build 7.u9_2.3.3-1-x86_64)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)

...even after I have set JAVA_HOME and added /opt/java6/bin to my PATH in my .zshrc file.

How can I get PyCharm (or other applications) to use Oracle Java 6 instead of OpenJDK?

Thanks, and apologies if I've posted in the wrong place.

Other information that might be helpful:

  • Using Gnome 3 as DE
share|improve this question
up vote 3 down vote accepted

If I want to use a different version of Java I do two things:

  • First, set JAVA_HOME as appropriate for that installation of Java and export it.
  • Then, update my path with `PATH=${JAVA_HOME}/bin:${PATH}.

Due to the way the PATH is searched, if you add to end of the path, the new version won't be used. Anything added to the end of the path only adds new commands, it does not replace existing commands. Prepending to the PATH variable will use command in the new directory in preference to other command.

Commands like java often involve a number of symbolic links before you get to the program. Using ${JAVA_HOME}/bin bypasses any indirections, and provides a direct path to the various Java related commands.

EDIT: If you want to run only certain programs with a different version of Java you could use a wrapper like this:

# javawrapper - replace Java for a command.
export JAVA_HOME=$1; shift

You can then call the wrapper with a command like.

javawrapper /opt/java6 PyCharm

You could also add an alias to your ~/.bashrc file like this

alias PyCharm='javawrapper /opt/java6 PyCharm'
share|improve this answer
Well, that solves half the problem; I was appending to the end, rather than the beginning of $PATH. But how do I only run the different version of Java for certain applications? – NT3RP Nov 17 '12 at 18:43
I've updated my response. However, in a case like yours, I have rarely need to keep programs using the default Java version. – BillThor Nov 17 '12 at 19:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.