• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Java in Linux

 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15480
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Frank Bacher
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18300
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would it matter setting the execution path if it did not work in the bin folder that contained javac?
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ran sudo apt-get install sun-java6-jdk and it works now. Does this mean I installed it twice?
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic