Results 1 to 5 of 5
- 04-24-2012, 07:39 PM #1
Member
- Join Date
- Apr 2012
- Posts
- 3
- Rep Power
- 0
Problem running Simple Hello world program in Ubuntu
Problem running Simple Hello world program in Ubuntu...
I have installed JDK7... copied it to /usr/lib/jvm/ directory and changed the Java Alternative
And use javac command to compile the program and it created a hello.class file
it compiled without any errorJava Code:javac hello.java
below is the code
But when i try to run the prgram using this commandJava Code:class hello{ public static void main(String[] args) { System.out.println("Hello World!"); } }
But i get this following errorsJava Code:java hello
At last line it says Could not find the main class: Hello. Program will exit.Java Code:Exception in thread "main" java.lang.UnsupportedClassVersionError: Hello : Unsupported major.minor version 51.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) at java.lang.ClassLoader.defineClass(ClassLoader.java:616) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) Could not find the main class: Hello. Program will exit.
Please help me ,i'm new to Java
- 04-24-2012, 07:50 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
Re: Problem running Simple Hello world program in Ubuntu
It look likes your Java Runtime version(6) is different to your JDK version(7).UnsupportedClassVersionError: Hello : Unsupported major.minor version 51.0
What says "java -version" in your terminal? (6?)
You have to change it....
- 04-24-2012, 07:58 PM #3
Member
- Join Date
- Apr 2012
- Posts
- 3
- Rep Power
- 0
Re: Problem running Simple Hello world program in Ubuntu
Last edited by teete; 04-24-2012 at 08:00 PM.
- 04-24-2012, 08:03 PM #4
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
Re: Problem running Simple Hello world program in Ubuntu
Yes, that was what I suspected ->
How do you changed the java alternative?
sudo update-alternatives --config java ?
Do you have selected the java 7 jre?
How To Install Oracle Java 7 (JDK) In Ubuntu ~ Web Upd8: Ubuntu / Linux blog
+ many other sites will give you an installation guide!Last edited by eRaaaa; 04-24-2012 at 08:13 PM.
- 04-24-2012, 08:08 PM #5
Member
- Join Date
- Apr 2012
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
Problem running DataGimmick program!!
By Bentino in forum New To JavaReplies: 1Last Post: 02-21-2012, 09:18 PM -
Simple program, simple problem
By taymilll in forum New To JavaReplies: 12Last Post: 06-20-2011, 05:12 AM -
Problem with running an external program via java
By g123456 in forum New To JavaReplies: 4Last Post: 12-30-2009, 05:06 PM -
Problem Running in Simple JSTL example
By arpitgadle in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 06-28-2009, 09:19 PM -
Not able to debug simple hello world program
By amit123solanki in forum New To JavaReplies: 1Last Post: 06-12-2008, 03:41 PM


2Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks