Results 1 to 5 of 5

Thread: java nightmare

  1. #1

    Post java nightmare

    I have serious problem with this small java program that could not run on opensuse 13.1; therefore, I'm looking for help resolve it. I downloaded this: linux x64 135.6mb jdk-8u20-linux-x64.rpm on opensuse 13.1. I wrote this little program from a tutorial book:

    /*
    This is just to try this sample java program
    Call this program Example.java
    */

    call Example {
    public static void main(String args[]) {
    double gallons; // holds the number of gallons
    double liters; // holds conversion to liters

    gallons = 10; // start with 10 gallons
    liters = gallons * 3.7854; // convert to liters
    System.out.println(gallons + " gallons is " + liters + " liters. ");
    }
    }

    * I saved the program as Example.java
    * I used chmod for permission to execute the program
    * Compile the program: javac Example.java
    * Run the program: java Example

    The result was series of errors:
    Exception in thread "main" java.lang.UnsupportedClassVersionError: Example:Unsupported major.minor version 52.0
    at java.lang.Classloader.defineClass1(Native Method)

    and more 14 lines of errors that's needless to write them here.

    Please could you check this program and point out where I did something wrong. Thanks

  2. #2
    Join Date
    Nov 2009
    Location
    West Virginia Sector 13
    Posts
    15,652

    Default Re: java nightmare

    Did you install Java??

  3. #3
    Join Date
    Dec 2009
    Location
    Prague
    Posts
    94

    Default Re: java nightmare

    You should have "class Example {" and not "call Example {"

    Quote Originally Posted by odeku View Post
    I have serious problem with this small java program that could not run on opensuse 13.1; therefore, I'm looking for help resolve it. I downloaded this: linux x64 135.6mb jdk-8u20-linux-x64.rpm on opensuse 13.1. I wrote this little program from a tutorial book:

    /*
    This is just to try this sample java program
    Call this program Example.java
    */

    call Example {
    public static void main(String args[]) {
    double gallons; // holds the number of gallons
    double liters; // holds conversion to liters

    gallons = 10; // start with 10 gallons
    liters = gallons * 3.7854; // convert to liters
    System.out.println(gallons + " gallons is " + liters + " liters. ");
    }
    }

    * I saved the program as Example.java
    * I used chmod for permission to execute the program
    * Compile the program: javac Example.java
    * Run the program: java Example

    The result was series of errors:
    Exception in thread "main" java.lang.UnsupportedClassVersionError: Example:Unsupported major.minor version 52.0
    at java.lang.Classloader.defineClass1(Native Method)

    and more 14 lines of errors that's needless to write them here.

    Please could you check this program and point out where I did something wrong. Thanks

  4. #4

    Default Re: java nightmare

    Thanks for the correction; this was typo error, instead of class Example, I wrote call Example. The problem has not been resolved. Even with class Example, the program still produces errors. Please I still need help to resolve this problem. Thanks.

  5. #5
    Join Date
    Nov 2009
    Location
    West Virginia Sector 13
    Posts
    15,652

    Default Re: java nightmare

    Well what are the errors?

    Was the code copied from a Windows source?? Remember that Windows end a line the a CR+Linefeed this can confuse things that expect just a line feed

Posting Permissions

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