• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using Java in Linux

 
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 4803
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic