LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-11-2010, 05:20 AM   #1
daudiam
Member
 
Registered: Mar 2010
Posts: 68

Rep: Reputation: 15
no PATH variable set but still javac working fine in Ubuntu. How ?


Hi

I thought that setting up the PATH variable was a must if we wanted to use java or javac commands on linux (preferably in the bashrc file), but I am able to use these commands anywhere without setting up the PATH variable.. Similarly, without specifying '.' in the CLASSPATH variable (in fact, not specifying the CLASSPATH variable at all), I am able to access class files in the same directory. How is it possible ?
 
Old 06-11-2010, 07:24 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2018 CentOS6.10 CentOS7.5 + 50+ other Linux OS, for test only.
Posts: 17,083

Rep: Reputation: 3486Reputation: 3486Reputation: 3486Reputation: 3486Reputation: 3486Reputation: 3486Reputation: 3486Reputation: 3486Reputation: 3486Reputation: 3486Reputation: 3486
One java path has been set up by default.
Usually gcc-java ? Please check with : java -version
( The set up is very simple : 2 links to /usr/bin/ : java + javac.)

Changing the java to e.g. sun-java :
( sun-java6-jdk must be installed.)

sudo update-alternatives --config java
... and choose sun.

CLASSPATH : Today it is "always" /usr/share/java/ , I think.
Is also set to that as default.
..

Last edited by knudfl; 06-11-2010 at 07:27 AM.
 
Old 06-13-2010, 12:39 AM   #3
daudiam
Member
 
Registered: Mar 2010
Posts: 68

Original Poster
Rep: Reputation: 15
Thanks, but does it mean there is another Java installed other than Sun Java 6, which we refer to when we type 'java' and 'javac' because it gets these commands at /usr/bin whereas java as such is installed somewhere else ?

When I type java -version it shows this :

Code:
daud@daud-laptop:~$ java -version
java version "1.6.0_15"
Java(TM) SE Runtime Environment (build 1.6.0_15-b03)
Java HotSpot(TM) Server VM (build 14.1-b02, mixed mode)
Here its showing its using java6

Also, when I type echo $CLASSPATH it shows nothing. Sorry i don't understand that CLASSPATH is the path that's searched in order to find out the class files. When its not set even then its able to find the class files in the present directory (and all books say that '.' must be included in the CLASSPATH for the present directory to be searched)
 
Old 06-13-2010, 01:24 AM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2018 CentOS6.10 CentOS7.5 + 50+ other Linux OS, for test only.
Posts: 17,083

Rep: Reputation: 3486Reputation: 3486Reputation: 3486Reputation: 3486Reputation: 3486Reputation: 3486Reputation: 3486Reputation: 3486Reputation: 3486Reputation: 3486Reputation: 3486
Sorry, I was wrong : No default libgcj* gij* in Ubuntu.
( You have an (old) genuine sun java = 1.6.0_15 ).

Still guessing : If you have a particular classpath,
you must point to it, like this example :
'java -classpath ".:./lib/alloy.jar:./lib/gnujaxp.jar:....." <Main>'

Options, please see : java -help
QUOTE : "" -classpath
<class search path of directories and zip/jar files>
A colon ( : ) separated list of directories, JAR archives,
and ZIP archives to search for class files. ""

A "standard" program ( Ubuntu package ) will probably
always use the jar files in /usr/share/java/ .
= The hard coded classpath.
The configuration of $CLASSPATH : Probably inside java itself.
..

Last edited by knudfl; 06-13-2010 at 11:31 AM.
 
Old 06-14-2010, 12:09 AM   #5
daudiam
Member
 
Registered: Mar 2010
Posts: 68

Original Poster
Rep: Reputation: 15
Actually, when I typed ls -l
Code:
/usr/bin/javac
it showed that the javac file here is actually a link to the /etc/alternatives directory's java. In the /etc/alternatives directory I typed
Code:
update-alternatives --list javac
, I got the actual location of the javac. The alternatives system is there to present the user with a single interface for accessing different programs, i.e. he could type javac to invoke the javac of any of Java's versions that are installed.

As for the classpath, the current directory is the default classpath

Last edited by daudiam; 06-14-2010 at 12:14 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you set the PATH variable ? DarkLeon Linux - Newbie 6 11-06-2006 03:26 PM
how to set $PATH variable definitely unihiekka Linux - Software 2 12-15-2005 10:12 AM
Where to set system PATH variable Cybers19 Linux - Newbie 4 05-05-2004 01:46 PM
after set up the search path, only javac works, why??? zhgalaxy Programming 1 04-25-2004 12:14 AM
How to set PATH How do I set PATH environment variable? Tranquil Linux - Newbie 3 11-02-2003 02:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration