java in mandrake linux 10.0 help

Reply

Join Date: Oct 2005
Posts: 3
Reputation: nabakishore is an unknown quantity at this point 
Solved Threads: 0
nabakishore nabakishore is offline Offline
Newbie Poster

java in mandrake linux 10.0 help

 
0
  #1
Oct 22nd, 2005
i'm using mandrake linux 10.0 . i have installed java compiler successfully. but when i'm trying to use the comand "javac" it is not working. the following are the typical outputs plz help.........

[nabakishore@10 Clock]$ ls
Clock.class Clock.java example1.html
[nabakishore@10 Clock]$ javac Clock.java
bash: javac: command not found
[nabakishore@10 Clock]$ java Clock
Exception in thread "main" java.lang.UnsupportedClassVersionError: Clock (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
[nabakishore@10 Clock]$
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 609
Reputation: freesoft_2000 is an unknown quantity at this point 
Solved Threads: 7
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Re: java in mandrake linux 10.0 help

 
0
  #2
Oct 22nd, 2005
Hi everyone,

Please list exactly what you are typing at the command line

Richard West
Microsoft uses "One World, One Web, One Program" as a slogan.
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond

Tell me what type of software do you like and what would you pay for it

http://www.daniweb.com/techtalkforums/thread19660.html
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: java in mandrake linux 10.0 help

 
0
  #3
Oct 22nd, 2005
That's different JVM implementations. You're getting the major/minor version error, because you might have compiled a project in 1.5 and trying to run it on 1.4.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 609
Reputation: freesoft_2000 is an unknown quantity at this point 
Solved Threads: 7
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Re: java in mandrake linux 10.0 help

 
0
  #4
Oct 22nd, 2005
Hi everyone,

Originally Posted by server_crash
That's different JVM implementations. You're getting the major/minor version error, because you might have compiled a project in 1.5 and trying to run it on 1.4.
server_crash, you mean you can't compile a java file in 1.5 and run it in 1.4 although the vice-versa works?

Richard West
*****************************************************
Microsoft uses "One World, One Web, One Program" as a slogan.
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond

Tell me what type of software do you like and what would you pay for it

http://www.daniweb.com/techtalkforums/thread19660.html
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: java in mandrake linux 10.0 help

 
0
  #5
Oct 22nd, 2005
Exactly. 1.5 is suppose to be backward compatible when you compile with the 1.4 source flag, but the JVM implementation is still different, which in turn causes the major/minor version error. I had this same problem a while back. I compiled the source in perfect 1.4 syntax, but it gave me the same error. I then tried to compile with the 1.4 -source flag, but that didn't help any. After that, I learned that the implemenation details were still different no matter what. Of course, if you use 1.5 syntax it definately won't work on 1.4 JVMs and JREs. It's weird since they call it backward compatible, but it's really not.
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 3
Reputation: nabakishore is an unknown quantity at this point 
Solved Threads: 0
nabakishore nabakishore is offline Offline
Newbie Poster

Re: java in mandrake linux 10.0 help

 
0
  #6
Oct 22nd, 2005
Originally Posted by freesoft_2000
Hi everyone,

Please list exactly what you are typing at the command line

Richard West
when i'm typing "javac hello.java" in comandline after entering in that directory it is saying
bash: javac comand not found

but when i'm copying the hello.java into /java/bin/ and cd to /java/bin/ and typing "./javac hello.java" it is creating hello.class and its working

tell me how to run it if the .java file is in some other directory
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 609
Reputation: freesoft_2000 is an unknown quantity at this point 
Solved Threads: 7
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Re: java in mandrake linux 10.0 help

 
0
  #7
Oct 22nd, 2005
Hi everyone,

Originally Posted by nabakishore
when i'm typing "javac hello.java" in comandline after entering in that directory it is saying
bash: javac comand not found
Yours is a classic classpath error.

Do this

  1. javac cp hello.java

It'll work now. Remember to type the location of your file and not only hello.java. The same goes for the javac compiler

Richard West
*****************************************************
Microsoft uses "One World, One Web, One Program" as a slogan.
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond

Tell me what type of software do you like and what would you pay for it

http://www.daniweb.com/techtalkforums/thread19660.html
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 3
Reputation: nabakishore is an unknown quantity at this point 
Solved Threads: 0
nabakishore nabakishore is offline Offline
Newbie Poster

Re: java in mandrake linux 10.0 help

 
0
  #8
Oct 22nd, 2005
thank u Mr Richard West . but the cp option is not working , rather the following is working

[nabakishore@10 nabakishore]$ javac -d /home/nabakishore/ HelloWorld.java
[nabakishore@10 nabakishore]$ java HelloWorld
Hello, World
[nabakishore@10 nabakishore]$
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,144
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: java in mandrake linux 10.0 help

 
0
  #9
Oct 23rd, 2005
If you add the -source 1.4 flag you will NOT get 1.4 compatible classfiles. All that does is flag 5.0 only features as errors in the code, effectively ensuring whether it would compile using a 1.4 compiler.
You also need to add the -target 1.4 flag.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 71
Reputation: Kate Albany is an unknown quantity at this point 
Solved Threads: 1
Kate Albany Kate Albany is offline Offline
Junior Poster in Training

Re: java in mandrake linux 10.0 help

 
0
  #10
Oct 23rd, 2005
Hello,

Background

The reason you are receiving the 'UnsupportedClassVersionError' is because the 'bash' shell is finding the default installed 'java' bundled with MDK (Mandrake) 10. You can find which 'java' or 'javac' (or any command) will be run by bash by entering the following command:

  1. which <command>
For instance, below is the output I get on my machine when I want to see which java binary will be run:

  1. kate@pioneer:[~]$ which java
  2. /home/kate/jdk.1.5.0.03/bin/java
I suspect yours may be running '/usr/bin/java'. This is the 'Kaffe Virtual Machine' environment and not much good for anything except taking up disk space. It lacks compatibility in many ways with the current releases of Java.

Originally Posted by nabakishore
bash: javac comand not found
This is an error being raised by the bash shell, as it cannot locate an executable called 'javac' in the locations specified in your 'PATH' environment variable.

Originally Posted by nabakishore
but when i'm copying the hello.java into /java/bin/ and cd to /java/bin/ and typing "./javac hello.java" it is creating hello.class and its working
The bash shell cannot locate the 'javac' binary because you have installed the JDK directly into the root directory. The reason that executing './javac hello.java' works (after you have copied hello.java into that directory and changed directory to that path) is because by placing './' in front of 'javac' overrides your PATH environment variable and instructs bash to search for the binary called 'javac' in the current working directly only, which of course it finds.

Solution

Originally Posted by nabakishore
tell me how to run it if the .java file is in some other directory
You need to add '/java/bin/' to your sessions PATH environment variable. To do this enter the command as below:

  1. export PATH=/java/bin/:$PATH
However when you close your shell session or begin a new one you will have to re-export this path. To make this change permanent (so it is set automatically each time you start a new shell session) you need to place this into your '.bashrc' (bash resource) file. This file is located in your home directory. For example my '.bashrc' file is located in the following location '/home/kate/.bashrc'. Simply add the command above to the end of this file.

For future reference

It is bad practice to install software into the root directory on Linux. You should install the JDK (or any software for use by you only) into your home directory. If you want to install something which can be accessed by any other user of the machine you should install it under the '/usr/local/' directory as the root user.

If you want to rectify this you can move the installed JDK into your home directory by issuing the following command:

  1. mv /java /home/<your_user_name>/
Now just change the line you added to the '.bashrc' file to point to '/home/<your_user_name>/java/bin' instead.

Hope this helps,

Kate
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC