compile java
i am using ubuntu linux. i installed jdk.
but i cann't compile java programmes. because linux can'tbe identify the javac command. how can i solve that problem? -jeyram-:tisk: |
It sounds like you need to add java's bin directory to your path. Can you post the exact error message?
|
1st, instructions from java.sun.com
Quote:
If not, here is what Sun says about it: http://java.sun.com/j2se/1.4.2/docs/...classpath.html :twocents: |
Yes, it's better to use the package provided in the Ubuntu repositories. The alternative is to edit /etc/profile or bash_profile, set up update-alternatives, etc. - a lot of work that you can easily spare yourself.
|
just find the path to your javac and java executables and add them to your path like this: export PATH=$PATH:/(path to javac):/(path to java)
You could also create a startup script that did this for you or modify the bash_profile or bashrc like mentioned above+ |
yap it's working. I understood what's happen. Javac is response for compilation. So if you want to do manually then you have to mention that path (like shell script).
Ex: ./jdkinstallationdirectory/bin/javac filename If you export this path then Linux can find javac command automatically. But I want to know some thing. In Windows after the jdk installation If the os want to recognize javac then we have to set JAVA_HOME variable for compile java files (now I started to shift Linux environment). I read from a PDF book that they mention about setenv command to create variable JAVA_HOME in Linux (for compilation purpose like export path). But I can’t find setenv command in my linux (Ubuntu). Is that method true? * I want to know this thing just for my knowledge. |
Quote:
|
Usually, you set both JAVA_HOME and add it to your $PATH variable. You can do both by adding 'export' commands (like in Hondo's post) to your .bashrc or the system-wide /etc/bashrc files.
Typically, the commands look something like this: Code:
export JAVA_HOME="/path/to/jdk" #or to jre Code:
export LD_LIBRARY_PATH="${JAVA_HOME}/lib:${JAVA_HOME}/jre/lib:${LD_LIBRARY_PATH} |
All times are GMT -5. The time now is 11:23 AM. |