wood burning stoves 2.0*
The moose likes Linux / UNIX and the fly likes Installing Java on Linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Installing Java on Linux" Watch "Installing Java on Linux" New topic
Author

Installing Java on Linux

Ravi Kanth D
Greenhorn

Joined: Sep 14, 2003
Posts: 18
I have downloaded the Java 2 SDK and the IDE combo package from Sun.com and have installed it. But strangely there was no info as to what class paths I need to set under Linux and how to do it? Can anyone plz help? Thanks.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

You don't need to set the classpath; the default setting (none) is fine, at least at first. You will need to set your path so that your shell can find Java. Have a look at /usr/java/j2sdk1.4.2/ , or thereabouts. This should be your JDK install directory. Put ${JDK_HOME}/bin on your path; something like this in ~/.bashrc should be fine:

[ September 24, 2003: Message edited by: Ernest Friedman-Hill ]

[Jess in Action][AskingGoodQuestions]
Ravi Kanth D
Greenhorn

Joined: Sep 14, 2003
Posts: 18
Hey...sorry....but I couldn' find that .bashrc file? Where exactly is it located...since you said I have to add the PATH thing to this code rt?
Ravi Kanth D
Greenhorn

Joined: Sep 14, 2003
Posts: 18
I would also aappreciate if you can give a little explanation on the code you have mentioned. I was wondering since in the first line we mentioned the location of Java in "JAVA_HOME"...do we also need to mention the same in the second line like this: PATH="${JAVA_HOME}/bin:${PATH}" ??
himanshu patel
Ranch Hand

Joined: Feb 03, 2003
Posts: 205
.bashrc is a hidden file.You will find in your home directory.
Since it is hidden file, you need to use command like this.
vi .bashrc
Essentially to view all hidden files in linux you have to prefix (.)
along with file name


If you want to become a rich, do not work for others but make others to work for you.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
It could be that .bashrc was not created. Then simply create such a file.
JAVA_HOME is the install directory for your SDK. The path must point to
the bin of the JAVA_HOME dir.
Explanation:
JAVA_HOME is read by some applications e.g. Apache, Ant to detect the home folder, to be able to find the JRE etc.
PATH: is processed by the shell to find the java commands (java, javaw, javac etc.)
This is why you have to set both. In Linux (also in Windows) your PATH variable is the search path for commands which aren't in the local directory. So when you are in a shell and type "cp" then the shell searches in all you path folders (in this case it would be /bin/)
[ September 24, 2003: Message edited by: Oliver Refle ]
Ravi Kanth D
Greenhorn

Joined: Sep 14, 2003
Posts: 18
Thanks for the info...and my question is:
so in the second line of the code above...it should not be JDK_HOME....but it should be JAVA_HOME which was mentioned in the first line right?
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
JAVA_HOME is the standard variable. There are also some tools
which require JDK_HOME (think netbeans IDE, but i am not sure).
Normaly when you start such a tool it will tell you it couldn't
find the desired variable.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34


so in the second line of the code above...it should not be JDK_HOME....but it should be JAVA_HOME which was mentioned in the first line right?

Sorry, just being sloppy. I fixed my original post.
Ravi Kanth D
Greenhorn

Joined: Sep 14, 2003
Posts: 18
I saw the .bashrc file and it doesn' have anything about PATH in it. On the other hand, there is a file bash_profile (I think) in my Home directory which has PATH mentioned in it. So do I add the above code to that bash_profile file then? Sorry...but being a starter in Linux everything seems so confusing rt now.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

There are several different startup files that bash can use -- both of those, plus several system-wide files in /etc.
The best thing to do is to say "info bash" at the prompt, then type
"gBash Startup Files" and press Enter; then read this section of the Bash manual which explains it all.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Installing Java on Linux
 
Similar Threads
How close to real exam?
java and linux
Uninstalling java on linux
How close to real exam?
What about OS ?