Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
03-23-2007, 12:56 PM
|
#1
|
Member
Registered: Nov 2006
Location: Luxembourg
Distribution: Suse 10.1
Posts: 36
Rep:
|
Compiling and launching java from the terminal
Hello, i try to compile and make run my java files from terminal
I have installed the Sun jre 1.5 package that commes with the installation package of Linux and i have installed the new version the 1.6 from Sun too. Then i have the 2 version in my laptop (1.5 in /usr.... and the other one in /opt/....).
Previously i have set the path of the javac like that: export PATH=$PATH:/path/to/java/bin
Then, after compiling the file i try to launch the file and a message error is sent:
marco@marco-laptop:~/Project/JFiles> javac Cejemplo01.java
marco@marco-laptop:~/Project/JFiles> java Cejemplo01
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
marco@marco-laptop:~/Project/JFiles>
its a simple code and i dont think i made a mistake doing that.
Thanks in advance
|
|
|
03-23-2007, 01:02 PM
|
#2
|
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019
Rep:
|
If you're going to do software development, you need jdk instead of jre.
|
|
|
03-23-2007, 03:44 PM
|
#3
|
Member
Registered: Nov 2006
Location: Luxembourg
Distribution: Suse 10.1
Posts: 36
Original Poster
Rep:
|
class Cejemplo01{
public static void main(java.lang.String[] args){ // or public static void main(String[] args){
System.out.println("Mi primera aplicacion en Java");
}
}
|
|
|
03-24-2007, 02:06 AM
|
#4
|
Senior Member
Registered: Jan 2005
Location: North America
Distribution: Debian testing Mandriva Ubuntu
Posts: 2,687
Rep:
|
I'm no expert in this field, but allot of people don't set up Java correctly, on this web page is a link called "java runtime Plugin". The site is for Fedora 6, but the java set up should apply to most, pay attention to "Note" regarding compatible libraries, and under that is a section called "Controlling Java through 'alternatives'" which might tip you in the right direction.
http://www.mjmwired.net/resources/mj...-fc6.html#java
|
|
|
03-24-2007, 03:08 PM
|
#5
|
Member
Registered: Jun 2005
Posts: 202
Rep:
|
You have too many curly brackets and also one is in the comments.
Edit appropriately.
|
|
|
03-24-2007, 03:51 PM
|
#6
|
LQ Guru
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019
Rep:
|
Not true, the code is perfectly sound. I really don't see any superfluous brackets; sure, there is one in the comment but by definition anything appearing in comments gets ignored by the compiler - so there isn't any problem at all, really.
That being said, it's my understanding that this issue is solved; I think Marco posted this bit of code only to show it is.
Last edited by jay73; 03-24-2007 at 03:55 PM.
|
|
|
03-25-2007, 03:33 AM
|
#7
|
Member
Registered: Nov 2006
Location: Luxembourg
Distribution: Suse 10.1
Posts: 36
Original Poster
Rep:
|
i found the solution, i was using two different java version.
i just replace the java and javac from the usr/lib/ and now i can compile and run my java code.
Thanks for your replies
|
|
|
03-25-2007, 03:43 AM
|
#8
|
Member
Registered: Jul 2005
Location: USA
Distribution: F10 (x86_64)
Posts: 549
Rep:
|
That works now, but the next time you have an update of gcj, its going to wipe those files. I don't use suse, but there's a proper way to set up java along with gcj. It's up to you to find out.
|
|
|
All times are GMT -5. The time now is 02:30 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|