LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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


Reply
  Search this Thread
Old 03-23-2007, 12:56 PM   #1
marcoguillen
Member
 
Registered: Nov 2006
Location: Luxembourg
Distribution: Suse 10.1
Posts: 36

Rep: Reputation: 15
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
 
Old 03-23-2007, 01:02 PM   #2
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 133Reputation: 133
If you're going to do software development, you need jdk instead of jre.
 
Old 03-23-2007, 03:44 PM   #3
marcoguillen
Member
 
Registered: Nov 2006
Location: Luxembourg
Distribution: Suse 10.1
Posts: 36

Original Poster
Rep: Reputation: 15
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");
}
}
 
Old 03-24-2007, 02:06 AM   #4
Junior Hacker
Senior Member
 
Registered: Jan 2005
Location: North America
Distribution: Debian testing Mandriva Ubuntu
Posts: 2,687

Rep: Reputation: 61
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
 
Old 03-24-2007, 03:08 PM   #5
whk
Member
 
Registered: Jun 2005
Posts: 202

Rep: Reputation: 37
You have too many curly brackets and also one is in the comments.
Edit appropriately.
 
Old 03-24-2007, 03:51 PM   #6
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 133Reputation: 133
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.
 
Old 03-25-2007, 03:33 AM   #7
marcoguillen
Member
 
Registered: Nov 2006
Location: Luxembourg
Distribution: Suse 10.1
Posts: 36

Original Poster
Rep: Reputation: 15
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
 
Old 03-25-2007, 03:43 AM   #8
jlo_sandog
Member
 
Registered: Jul 2005
Location: USA
Distribution: F10 (x86_64)
Posts: 549

Rep: Reputation: 32
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
java and terminal window commands manolakis Programming 4 02-03-2007 10:27 PM
Launching a program as root without using the terminal Crushing Belial Linux - Software 2 11-20-2005 10:38 PM
How to work in a new TERMINAL in JAVA nedian123 Programming 1 12-18-2004 11:51 AM
Compiling from sources - Launching Apps... ArthurDent Linux - Newbie 3 07-10-2004 08:57 AM
StarOffice7 Installation java terminal snash Linux - Software 2 02-06-2004 11:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration