0

I'm working on a Linux computer with several users. One of the users is currently running a java program, but I need to re-install the JDK as I'm getting an unsupported major.minor error. The JDK doesn't even seem to be installed (typing javac -version just gives me a list of packages where I can get the compiler).

Can I install the JDK without having to stop the other user's java program?

user28898
  • 43
  • 4

2 Answers2

5

Just install the new JDK in a different directory, you can have many different JVMs and versions installed on one computer. You shouldn't affect any of the other users.

Related: How to install a second JVM?

Community
  • 1
  • 1
durron597
  • 31,968
  • 17
  • 99
  • 158
-1

if you are getting the following error:

java.lang.UnsupportedClassVersionError: test_hello_world :
 Unsupported major.minor version 51.0

the you must follow the following thing written below:

The reported major numbers are:

J2SE 8 = 52,
J2SE 7 = 51,
J2SE 6.0 = 50,
J2SE 5.0 = 49,
JDK 1.4 = 48,
JDK 1.3 = 47,
JDK 1.2 = 46,
JDK 1.1 = 45

To fix the actual problem you should try to either run the Java code with a newer version of Java JRE or specify the target parameter to the Java compiler to instruct the compiler to create code compatible with earlier Java versions.

For example, in order to generate class files compatible with Java 1.4, use the following command line:

javac -target 1.4 HelloWorld.java

if you really want to install different version the follow:

If you download the linux binary from http://java.com/en/download/help/linux_install.xmlyou can install it in whatever directory you like. Then just reference those libs in your code, and you're good to go.

With the binary installer, it'll create its own named subdirectory (e.g. in your example, /usr/java/jdk1.5.0_), so you can download as many as you want, and they'll line themselves up in appropriately named sub-drectories.

The main java binary lives in /usr/bin, so if you want to replace that to the point where when you type "java" it accesses your java, and not that one, you just move the old one out of /usr/bin, and link your new one in there. Typing which java will tell you what the default java on your system is.

Piyush Mittal
  • 1,860
  • 1
  • 21
  • 39