LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   compile java (https://www.linuxquestions.org/questions/linux-general-1/compile-java-568296/)

jeyram 07-10-2007 11:42 PM

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:

gilead 07-11-2007 12:03 AM

It sounds like you need to add java's bin directory to your path. Can you post the exact error message?

gr8scot 07-11-2007 12:18 AM

1st, instructions from java.sun.com
 
Quote:

Originally Posted by jeyram
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:

Have you tried using the free jsdk from Debian? It might be easier than figuring out all the classpath stuff.

If not, here is what Sun says about it:

http://java.sun.com/j2se/1.4.2/docs/...classpath.html

:twocents:

jay73 07-11-2007 06:40 AM

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.

hondo 07-11-2007 01:36 PM

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+

jeyram 07-12-2007 10:53 PM

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.

jlliagre 07-13-2007 01:20 AM

Quote:

Originally Posted by jeyram
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?

That method is true but only applies to csh and its clones. The equivalent with sh/bash/ksh/zsh is the export builtin.

timmeke 07-13-2007 03:17 AM

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
export PATH="${JAVA_HOME}/bin:${JAVA_HOME}/jre/bin:${PATH} # leave out the 2nd part if you only have the jre

You can also add an export for the Java libs, but that's optional.
Code:

export LD_LIBRARY_PATH="${JAVA_HOME}/lib:${JAVA_HOME}/jre/lib:${LD_LIBRARY_PATH}
#again leaving out the 2nd part if you only have the jre installed



All times are GMT -5. The time now is 11:23 AM.