LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 07-10-2007, 11:42 PM   #1
jeyram
LQ Newbie
 
Registered: Jun 2007
Distribution: Ubuntu
Posts: 26

Rep: Reputation: 15
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-
 
Old 07-11-2007, 12:03 AM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 151Reputation: 151
It sounds like you need to add java's bin directory to your path. Can you post the exact error message?
 
Old 07-11-2007, 12:18 AM   #3
gr8scot
Member
 
Registered: Jun 2007
Distribution: Debian
Posts: 73

Rep: Reputation: 16
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-
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

 
Old 07-11-2007, 06:40 AM   #4
jay73
Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
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.
 
Old 07-11-2007, 01:36 PM   #5
hondo
Member
 
Registered: Jul 2005
Location: norway
Posts: 198

Rep: Reputation: 33
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+
 
Old 07-12-2007, 10:53 PM   #6
jeyram
LQ Newbie
 
Registered: Jun 2007
Distribution: Ubuntu
Posts: 26

Original Poster
Rep: Reputation: 15
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.
 
Old 07-13-2007, 01:20 AM   #7
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Mint, OL
Posts: 9,499

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
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.
 
Old 07-13-2007, 03:17 AM   #8
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
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
 
  


Reply

Tags
compile, debian, free, java


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Programming: Java Runtime Environment not found when trying to compile murbz Linux - Software 2 03-26-2009 03:04 AM
compile java JDK 1.4 kernelvn *BSD 2 06-21-2005 09:42 PM
cant compile java tanveer Programming 7 11-25-2004 09:49 PM
Compile Java - .class, .java, .jar ? woranl Programming 2 11-09-2004 10:12 PM
compile and run java pelegk2 Programming 3 10-05-2004 09:28 AM


All times are GMT -5. The time now is 09:25 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration