ckrudelux Posted November 14, 2011 Share Posted November 14, 2011 I have executed in my terminal with success generating a class file.javac HelloWorldApp.java But then I type to execute the program I get some errors:java HelloWorldApp Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorldApp : Unsupported major.minor version 51.0at 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: HelloWorldApp. Program will exit. What... is where a setup I missed? This should be a simple "hello world" output HelloWorldApp.java /*** 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. }} Edit:I have tried with adding the option -cp aka -classpath with no luck.java -cp . HelloWorldApp Have tried several paths none of them have worked out for me...///home/ckrudelux/Documents/Java/ Edit: Have checked version of my Java and I get 1.7 from javac and 1.6 from java, I have read that mixed versions can be a problem but I only installed the JDK 7 so I don't know why I got JDK 6 as well in my etc folder, checked with an other computer which I haven't installed JDK and can't find any JDK installed so the JDK 6 must had come from the JDK 7 installation. Edit: I have now tested to compile a broken code by removing the ";" at the end and got as suspected an error by the compiler, added the ";" again and complied it, also tested to execute the program and it worked. I have no clue on what was wrong but I guess encoding but would that pass the compiler in what case? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.