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 ? |
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. .. |
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 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) |
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. .. |
Actually, when I typed ls -l
Code:
/usr/bin/javac Code:
update-alternatives --list javac As for the classpath, the current directory is the default classpath |
All times are GMT -5. The time now is 07:56 PM. |