[java] Linux and Java -- run and compile from shell

Started by
3 comments, last by Will F 18 years, 6 months ago
Okay at my university all comps are Linux boxes. I myself got Ubuntu working fine duel booting with WinXp via the NTBootLoader. Installed the KDE (Kubuntu), and em happily enjoying Linux. Now, I installed the JR5+Netbeans SDK, that all went fine. However I am still running into a delima I don't know how to solve. On the comps at school it is easy as typing "javac class.java" to compile and "java class" to run. I wish to have the same functionality but I do not. What do I have to configure within Linux to be able to compile and run java.
Advertisement
This is a guess, but java and javac are not in your shell's path... try adding them to it.

Tutorial Link
BRING BACK THE BLACK (or at least something darker)
How on earth do I append
export PATH=$PATH:~/j2sdk1.4.2/bin
to the .bashrc on the root drive...

I cannot make heads or tails of "vi"
I also cannot figure out how to change the permissions so I can edit the /root/.bashrc file from the GUI.
Quote:Original post by Halsafar
How on earth do I append
export PATH=$PATH:~/j2sdk1.4.2/bin
to the .bashrc on the root drive...

First, it is my opinion that vi is overkill for simple tasks like this, just use nano to edit the file. Furthermore, you don't need to export the path on the root account - it's only relevant for any account that will run or compile Java programs. Since you shouldn't be using root for such tasks, you only need to modify your .bashrc. To do this, open a terminal and type :

[will@localhost] > nano -w ~/.bashrc
** nano will pop up, as will the contents of your bashrc file
** go to the bottom and type
export PATH=$PATH:~/j2sdk1.4.2/bin (or whatever your Java path is)

Hit Ctrl + X (save), type "Y", and press Enter.

All done.
- stormrunner
Here's some info for Adding a Directory to the Path.

You could also take a look at the gcj java compiler. Installing it with Ubuntu's package management software should be easy.

This topic is closed to new replies.

Advertisement