• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to set up java in linux?  RSS feed

 
Edgardo Lara
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jdk1.5.0_05 is in /opt
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

I'm going to move this question to our Linux/UNIX forum.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main thing you need to do is set the PATH variable for your user. You can do this by modifying a file in your users directory. The exact file name depends on which shell you use. For example, if you are using bash, then open ~/.bashrc in your favorite text editor and add the following line at the end:

PATH=$PATH:/opt/jdk1.5.0_05/bin

Then the next time you open a terminal, you can just type commands like "javac" and "java" to compile and run your own Java programs.

HTH

Layne
 
Peter Rooke
Ranch Hand
Posts: 900
7
Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Even better, download the J2SE SDK with NetBeansIDE Bundle. Then install via the install program.
[ October 09, 2005: Message edited by: Peter Rooke ]
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Peter Rooke:


Even better, download the J2SE SDK with NetBeansIDE Bundle. Then install via the install program.

[ October 09, 2005: Message edited by: Peter Rooke ]


Personally, I would recommend leaving out the CLASSPATH variable. The defaults without this variable are just fine for a beginner.

Layne
 
Edgardo Lara
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created java.sh under /etc/profile.d

which contain the ff:

export JAVA_HOME=/opt/jdk1.5.0_05
export PATH=$PATH:$JAVA_HOME/bin

It successfully run a Sample.java

my follow up question is:

1. why the version is still java version "1.4.2"?
2. where is the preferable location of the jdk? is it in /opt OR /usr/local? any difference?
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) because there is a second (a first) JDK (at least jre) installed, and this is found first in the path.

find out where it is with .

2) There is no preference from java, there is no preference for linux.
If you don't have preferences - there is no.

My preference is to install JDKs to opt like this:


If there is a new jdk-1.5.1, I may install it there too, link jdk-1.5 to new version and keep the old for sure.

JAVA_HOME is allways /opt/java.
No fiddling with the path is needed.
Switching between 1.4 and 1.5 was easy (but is rarely used the last months).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!