-1

I'm new using Java and I want to execute a Java program from unix, While I'm trying to execute it I'm getting an the following error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: javaapplicationtest/JavaApplicationTest : Unsupported major.minor version 52.0

I'm using:

java -jar JavaApplicationTest.jar

Do you have any idea how to correct that error?

Javier Salas
  • 1,064
  • 5
  • 15
  • 38
  • Upgrade your Java to latest version. – talex Dec 15 '16 at 18:25
  • I have the latest version of java. Product Version: NetBeans IDE 8.1 (Build 201510222201) Java: 1.8.0; Java HotSpot(TM) 64-Bit Server VM 25.0-b70 – Javier Salas Dec 15 '16 at 18:27
  • 1
    Do you have multiple instances of JDK/JRE installed on your system? Check the version of java you are running by executing "java -version" and confirm that it is 1.8 – Chetan Jadhav CD Dec 15 '16 at 19:02
  • This is what I got from unix: java version "1.6.0_101" Java(TM) SE Runtime Environment (build 1.6.0_101-b14) Java HotSpot(TM) Server VM (build 20.101-b01, mixed mode) – Javier Salas Dec 15 '16 at 19:12
  • Possible duplicate of [How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version](http://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi) – radoh Dec 15 '16 at 21:38

1 Answers1

0

You seem to have multiple JDK/JRE versions installed on your system. The code you're trying to run is compiled for JRE 1.8, while the version of java on your PATH is 1.6.

You could do the following things to get your program to run:

  1. Modify your environment variables such that when you try to execute java, it is picking up the 1.8 version. Look up how to do that on the specific UNIX flavor you are running.
  2. If you are compiling the source code yourself, you could change the target runtime to be able to run this code on earlier versions. javac -target 1.4 JavaApplicationTest.java
Chetan Jadhav CD
  • 1,116
  • 8
  • 14
  • This is what i got when I'm doing it with 1.4: `javac: target release 1.4 conflicts with default source release 1.5` I tried with 1.5 and I got this: `error: Class names, 'TestJFrame.jar', are only accepted if annotation processing is explicitly requested 1 error` – Javier Salas Dec 15 '16 at 19:47
  • Your code seems to be incompatible with previous versions of java so you'll be better off following the first approach, since you also have JDK 1.8 installed somewhere on your system (I assume) – Chetan Jadhav CD Dec 15 '16 at 20:02