LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-10-2005, 05:41 PM   #1
KissDaFeetOfSean
LQ Newbie
 
Registered: Jun 2005
Posts: 27

Rep: Reputation: 15
Java 1.5 Compiler


Hello everyone,
I am a person completely new to programming and to Linux, so please bear with me. I am trying to install the new Java 1.5 compiler under Mandriva Linux 1.5. I went to this website at Sun and followed the directions to the letter, using the rpm installation:http://java.sun.com/j2se/1.5.0/insta...ml#install-pkg

I logged in as "root" so all users of my computer would be able to use the Java compiler. Now, when I'm in my home directory, and I use the vi editor to create a simple "Hello, Sean!" program and then try to compile it, I get this at the command prompt:

[swilliams@localhost ~]$ javac Hello.java
bash: javac: command not found
[swilliams@localhost ~]$ ./javac Hello.java
bash: ./javac: No such file or directory

Ok. So then I did some hunting in my file system, thinking that my "Java software" might be elsewhere then my home directory. So then I found the location of the JRE and JDK to be here:

[swilliams@localhost ~]$ cd /usr/java
[swilliams@localhost java]$ ls
jdk1.5.0_03/ jre1.5.0_03/
[swilliams@localhost java]$

So then, I copied the Hello.java program to the jdk1.5.0_03/ directory, and still no luck. So then I logged in as root, and compiled it and it compiled OK. Now, I DO NOT WANT to have to log in as root and change into that directory every time I write a java program obviously. Could someone please help me out here? Thank you in advance.

Sean W.
 
Old 07-10-2005, 06:48 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
You need to add the directory with the javac executable to your $PATH. You should do this in your shell start-up file to make it permanent. If you search these forums, you'll find plenty of examples for how to do this.
 
Old 07-10-2005, 07:26 PM   #3
KissDaFeetOfSean
LQ Newbie
 
Registered: Jun 2005
Posts: 27

Original Poster
Rep: Reputation: 15
Ok, I opened up my ".bash_profile" file under my home directory and commented out a line and add one, so it now looks like this:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

#PATH=$PATH:$HOME/bin <-------------------- LINE I COMMENTED OUT
PATH=$PATH:$HOME/bin:/usr/java/jdk1.5.0_03/bin/ <---------------LINE I ADDED

export PATH
unset USERNAME

But still no luck....here's what happens:

[swilliams@localhost ~]$ ./javac Hello.java
bash: ./javac: No such file or directory

I also tryed using "ln -s /usr/java/jdk1.5.0_03/bin/ /usr/bin" as root, but still no luck. :-(
 
Old 07-10-2005, 08:44 PM   #4
KissDaFeetOfSean
LQ Newbie
 
Registered: Jun 2005
Posts: 27

Original Poster
Rep: Reputation: 15
Ok...I figured it out. I went to this site: http://www.yolinux.com/TUTORIALS/LinuxTutorialJava.html

and edited my .bash_profile file like this:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

#PATH=$PATH:$HOME/bin
PATH=/usr/java/jdk1.5.0_03/bin:$PATH:$HOME/bin:./

export PATH
export JAVA_HOME=/usr/java/jdk1.5.0_03
export CLASSPATH=/usr/java/jdk1.5.0_03/lib/tools.jar:/usr/java/jdk1.5.0_03/jre/lib/rt.jar:./

unset USERNAME
~
 
Old 07-10-2005, 09:06 PM   #5
KissDaFeetOfSean
LQ Newbie
 
Registered: Jun 2005
Posts: 27

Original Poster
Rep: Reputation: 15
Incidentally,

for some reason now, when I execute my C programs.... i no longer have to type "./a.out"...I can just type "a.out" or the name of the executable...that's weird...anyone know why? And with Java, I can just use "java <name_of_class>" instead of prefixing <name_of_class> with "./"....I'm curious...can anyone tell me why...I don't know anything about shell scripting...
 
Old 07-10-2005, 09:45 PM   #6
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
Because you added the current working directory "." to your PATH. As a user, this isn't really a problem, but be careful when doing it as root, and always addd the current working directory to the END of the path (else you miught get surprised).
 
  


Reply



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
java compiler bluknight43 Linux - Software 3 05-11-2005 02:57 AM
java compiler athenerx Programming 33 06-30-2004 03:21 PM
Java Compiler? Alinuxnoob Programming 9 02-15-2004 10:00 PM
java compiler shamz Programming 2 10-26-2003 04:35 PM
Java and C compiler Eros_ Linux - Software 4 07-22-2003 06:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:59 PM.

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
Open Source Consulting | Domain Registration