Find the answer to your Linux question:
Results 1 to 2 of 2
Hi all, My java programs with correct syntax doesnt work.Even a hello world program. The reminal output is this: Code: [goktug@compaq-presario-cq62 src]$ java TextEditor Exception in thread "main" java.lang.UnsupportedClassVersionError: TextEditor ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2012
    Posts
    25

    Error running java classes


    Hi all,
    My java programs with correct syntax doesnt work.Even a hello world program. The reminal output is this:
    Code:
    [goktug@compaq-presario-cq62 src]$ java TextEditor
    Exception in thread "main" java.lang.UnsupportedClassVersionError: TextEditor : Unsupported major.minor version 51.0
    	at java.lang.ClassLoader.defineClass1(Native Method)
    	at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
    	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    	at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
    	at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    Could not find the main class: TextEditor. Program will exit.
    I couldn't figure out this, might be easy but..
    I need a detailed explanation on the solution, because I don't know much on using environment variables or else, so if you tell me sth like add this path, create this variable w/out how to do these jobs, I won't be able to do it.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,601
    What version of the JVM are you running (the command "java -version" will tell you)? In any case, the class loader is saying that the class TextEditor is from an unsupported version (Java 1.5.1 I think). I'm also suspicious of the indication in the top-most error that it is calling a native (JNI) method. What happens if you try a plain vanilla "Hello World" program? Here is an example (won't require a CLASSPATH environment to run):
    Code:
    /**
     * The HelloWorldApp class implements an application that
     * simply prints "Hello World!" to standard output.
     */
    class HelloWorldApp
    {
        public static void main(String[] args)
        {
            System.out.println("Hello World!"); // Display the string.
        }
    }
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •