wood burning stoves*
The moose likes Linux / UNIX and the fly likes Using Java in Linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Using Java in Linux" Watch "Using Java in Linux" New topic
Author

Using Java in Linux

James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

I have downloaded JDK6 and installed it, but when I try to do javac <filename> I get this.

The program 'javac' can be found in the following packages:
* gcj-4.1
* jikes-sun
* jikes-sablevm
* gcj-4.2
* kaffe
* jikes-classpath
* java-gcj-compat-dev
* ecj
* j2sdk1.4
* jikes-gij
* jikes-kaffe
* sun-java5-jdk
* sun-java6-jdk
Try: sudo apt-get install <selected package>
bash: javac: command not found


I have tried it at my desktop(where the java file is saved) and I have tried it in the bin folder where javac is actually found and it still does not work. Any Ideas? I have used Netbeans and it compiles fine so I'm pretty sure the installation is fine.


Visit my blog! http://jameshambrick.com
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4646
    
    5

you didn't specify which distribution you are using, but it sounds like you are having problems because /etc/alternatives is not set for Java.

Did you check that java is on your executable path?
have you done a:
which java
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Which version of which Linux distribution are you using?

I'm using Ubuntu 7.10 (and 8.04 beta) myself, and the best way to install Sun JDK 6 is to install it via the package management system (instead of downloading the setup file from Sun's website and installing it manually):

Most Linux distributions have a package management system to install software, but the commands may differ.
[ April 11, 2008: Message edited by: Jesper Young ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Frank Bacher
Greenhorn

Joined: Oct 25, 2002
Posts: 19
Have you already tried

(on Debian/Ubuntu. On other linuxes there is probably a command to configure the used Java, too).
[ April 11, 2008: Message edited by: Frank Bacher ]
James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

whoops. I have Ubunto 7.10. I did download it from Suns site. I then made the .tar/.bin file executable using chmod +x <filename> and then ran it like this
./<filename> went through and accepted all the agreements and everything. If it's easier to install using the Ubuntu installer then how do I get rid of what I installed? Will the Ubuntu installer just overwrite it and set the correct settings. I don't know how to set Java on my execution path.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15964
    
  19

Originally posted by James Hambrick:
whoops. I have Ubunto 7.10. I did download it from Suns site. I then made the .tar/.bin file executable using chmod +x <filename> and then ran it like this
./<filename> went through and accepted all the agreements and everything. If it's easier to install using the Ubuntu installer then how do I get rid of what I installed? Will the Ubuntu installer just overwrite it and set the correct settings. I don't know how to set Java on my execution path.


export JAVA_HOME=/usr/java/jdk1.6.xxxxx
export PATH=$JAVA_HOME/bin:$PATH

I loathe "alternatives". It's too complex, especially in the case of Java, where there's multiple items that need to be switched. So I ignore them and manually put the JVM I prefer in my path ahead of the alternatives java.

Note that the Sun JDK can live in any directory you want, though the RPM installs will put it in /usr/java by default. That's good enough for me, so even on non-Redhat (and even non-Linux) systems, I normally do likewise.


Customer surveys are for companies who didn't pay proper attention to begin with.
James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

Would it matter setting the execution path if it did not work in the bin folder that contained javac?
James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

I ran sudo apt-get install sun-java6-jdk and it works now. Does this mean I installed it twice?
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Originally posted by James Hambrick:
I ran sudo apt-get install sun-java6-jdk and it works now. Does this mean I installed it twice?


Probably.
Use locate javac to see, where javac might be found - one place or two of them.
which javac will show, what was installed well, so remove the other directory tree.


http://home.arcor.de/hirnstrom/bewerbung
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Java in Linux
 
Similar Threads
What is core.nnnn file? (nnnn is a 4-digit number)
Jikes ( can't find any classes )
Problems with Java Home in VMBox
Running a RMI Application
Install Tomcat on Linux