File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes exception at run time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "exception at run time" Watch "exception at run time" New topic
Author

exception at run time

satish bejju
Greenhorn

Joined: Jul 27, 2011
Posts: 11
i am new to java in linux forum

i installed and executed the command sudo update-alternatives --config java

and javac and java commands are worked properly

and i compiled my file by using javac Welcome.java
compiled fine but whent i am trying to run java Welcome i am getting following exception



Exception in thread "main" java.lang.UnsupportedClassVersionError: Welcome : 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: Welcome. Program will exit.




can anybody help in this

thanks,
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

This means you compiled with one version of Java and are trying to run with an earlier version. I forget exactly which numbers correspond to which versions, but I think 51 is java 7.

So do one of the following:

1. Compile with an earlier version of the JDK, one that is no newer than the version of the JRE that's on the linux box where you're going to run it.

2. Upgrade you JRE on the target machine to the same version you're compiling with.

3. Use the -source and -target options at compile time to produce a class file that is compatible with the version where you're going to run it. I'm not sure how well this works, but you can try it.
satish bejju
Greenhorn

Joined: Jul 27, 2011
Posts: 11
yes you are right jeff.
ifound all jdk's 1.5, 6, 7 under /usr/lib/jvm/

how to uninstall all .... can any one help

thank,
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

You don't necessarily have to uninstall anything. You can just set your PATH environment variable so the appropriate one comes first, or create shell scripts, functions, or aliases to invoke the desired executables by their respective full paths.

If you do want to uninstall, it depends on your flavor of Linux. Centos and some others have yum. Red Hat has rpm. Ubuntu has apt. I've used these for installing and upgrading. I don't know if they have uninstall options as well, but I'd assume so. There may also be a GUI-based tool on your system for maanging installed software. Or just executing rm -rf on the appropriate directories may be sufficient, but use caution when doing that!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: exception at run time
 
Similar Threads
Garbage collection & string literal pool
Exception in thread "main" java.lang.NoClassDefFoundError: Voice1
Package question
java command error
Hi , Iam ananya new to java tech,