Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

exception at run time

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic