2

I uninstalled Eclipse IDE due to this issue. Then I tried to run java program in my Linux mint Terminal. So I started with a small code

public class Myth{
public static void main(String[]args){
System.out.println("Hii There");
  }
}

and run it by giving commands javac Myth.java and java Myth but insted of giving output it gives the following error

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=Myth, offset=6
    at java.lang.ClassLoader.defineClassImpl(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:379)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:154)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:729)
    at java.net.URLClassLoader.access$400(URLClassLoader.java:95)
    at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:1184)
    at java.security.AccessController.doPrivileged(AccessController.java:732)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:604)
    at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:926)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:871)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:343)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:854)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:507)
1

This

java.lang.UnsupportedClassVersionError

means, that some of the libraries in your project are using diferrent version of java , and set accordingly in path. Quick things to resolve this:

$>which java

output->location of current java (eg. /usr/bin/java)

java --version

output->1.7.0 or 1.8.0 if this is the case , try switching version, for this do the following:

export JAVA_HOME=<path to diff java version sdk>
export PATH=$JAVA_HOME/bin:$PATH

This allows new path to come in front of old path, also for eclipse specific errors, take a look at eclipse cache in home directory(.eclipse folder in your project). You may safely delete this directory along ith .project files if any and recompile.

Edit: Offset=6 means your current version for java(JDK) is 1.6. Try switching it to later versions. Also check that you are using Jdk path and not jre path

  • after the command java --version terminal gives the following output JVMJ9VM007E Command-line option unrecognised: --version Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit. – usamypwd Jul 20 '18 at 6:12
  • java -v, would also do it, there should be no spaces. If it is then your current java path is something like (/usr/java/jre1.x.y/) instead it should be (usr/java/jdk/1.x.y) – Pavan Kate Jul 20 '18 at 6:16
  • my java path is /usr/java/jre1.8.0_171 and after changing that the error is still active – usamypwd Jul 20 '18 at 6:25
  • change it to /usr/java/jdk1.8.0_171 . If you dont have a jdk installed get it from oracle site by accepting icense agreement, its free. oracle.com/technetwork/java/javase/downloads/… see java jdk 1.8 u171, and download jdk – Pavan Kate Jul 20 '18 at 6:30
  • 1
    Reinstalled jdk and now it is working . Thanks @PavanKate – usamypwd Jul 20 '18 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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