Yandroide
Yandroide

Reputation: 91

Jar File is not executing on test pc

My jar file is working on the development machine but won't execute on test pc. I checked and found out that there is no jdk installed and I do not have installation rights on that specific PC. Is the lack of JDK the reason why I won't get a result? Here is what I got.

C:\Users\autosterileprocuser>java -jar C:\Users\autosterileprocuser\Documents\Sc
hedule.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: sterileProc/S
cheduleApp : Unsupported major.minor version 51.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$000(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: sterileProc.ScheduleApp. Program will exit.

Upvotes: 0

Views: 77

Answers (4)

Neeraj Krishna
Neeraj Krishna

Reputation: 1615

This is a compile version issue. Have a look at -target option of javac command (http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html). In Eclipse its available in Project Preferences -> Java Compiler. Set it to the target java you want to run the program.

Upvotes: 1

WhyIsItReal
WhyIsItReal

Reputation: 81

You are using an older version of Java. That's what java.lang.UnsupportedClassVersionError means, so simply update your Java on the test machine.

Upvotes: 0

vbazaga86
vbazaga86

Reputation: 156

To execute a jar file you will need a JRE Java Runtime environment but you dont need a JDK Java Development Environment.

The error indicates the installed JRE does not support java classes compiled with higher version of JDK you can use -target option of javac to specvify for wich version your classes will be compiled.

Upvotes: 0

Pierre
Pierre

Reputation: 863

This is a typical Java version problem. You are executing your jar with an older version of java than the one used to compile it.

Type java -version on both computers and you'll see the difference.

It happens for example when you compile your jar with the JDK7 and execute it with the JRE6.

Upvotes: 0

Related Questions