4

For example, I have OpenJDK 6 and 7 both installed. If I run javac foo.java will is compile my program as a Java 6 program or a Java 7 program?

user unknown
  • 6,892
Orcris
  • 521

3 Answers3

4

Debian-based distributions have so-called "alternatives" system, which allows to have more than one program installed which perform the same function (this also includes different versions of the same program, like Java 6 and Java 7). As @user15936 points out, the system works by manipulating symlinks, so "javac" can point to the executable either from OpenJDK 6 or from OpenJDK 7

The command to manipulate the above mentioned symlinks (the process is in fact more complex than that as it includes some configuration, for example manpages change too etc.) - is called update-alternatives. You can learn how to use it by typing man update-alternatives in terminal.

To directly answer your question, another way to determine which javac executable will be invoked is by doing

update-alternatives --display javac
Sergey
  • 44,353
1

The answer is whichever is linked to /usr/bin/javac

That will be executed.

You can see this by going to /usr/bin/ and see the link javac is connected by doing ls -l javac.

Bruno Pereira
  • 74,715
-1

You should type in a terminal javac -version and there you will get your answer...

doug
  • 17,212