compilation - Java Compiling Error in Command prompt: class file has wrong version 52.0, should be 50.0 -


this question has answer here:

i create java library program , used in java program .jar file. ide netbeans. tried same concept via command line , got following error:

class file has wrong version 52.0, should 50.0 please remove or make sure appears in correct sub directory of class path. import demo1_lib.test1; ^

this steps.

step 1: created following class library in netbeans ide.

  package demo1_lib;   /**   *   * @author tveluppillai  */ public class test1  {   public void print()    {     system.out.println("hello");   }      } 

step 2: create java project on netbeans , add jar file. (test1.jar) , consume class library function.

 package test2;   import demo1_lib.test1;   /**  *     * @author tveluppillai  */    public class test2    {     /**     * @param args command line arguments     */     public static void main(string args[])     {      test1 obj = new test1();      obj.print();            }   }  

this compiles fine , when ran, gives me right output in netbeans

however, when same thing using command prompt got error.

i used following command compile , run it.

javac -cp c:\\demo_lib\\test\\test1.jar test2.java 

i got following error:

class file has wrong version 52.0, should 50.0 please remove or make sure appears in correct sub directory of class path. import demo1_lib.test1; ^

what missing?

you trying run/reference class compiled jdk 8 using runtime/compiler jre/jdk 6.

the java being used command line different version 1 used netbeans.

see java class file list of numbers mean.

download jdk8, or if have it, add path , set java_home.

in unix:

export java_home=directory export path=$path:$java_home/bin