Topics:
DVR
nvrec
Mplayer
Links
Misc
Commands
Humor
New user
uploaded files
|
(linux_command_line)-> java compile/run |
submited by Russell Mon 23 May 05 Edited Thu 12 Jan 06 |
so I'm trying to learn java. I already had jre (java runtime) and I installed jdk (java development kit)
Now I know that I have jre installed cause Azureus works, but for some reason I do not understand, after installing the java rpms I found broken symlinks for both /usr/bin/java and /usr/bin/javac
I was able to fix this problem by ( as root) deleting those two symlinks and installing two new ones that work
ln -s /usr/java/jre1.5.0_02/bin/java /usr/bin/java
ln -s /usr/java/jdk1.5.0_03/bin/javac /usr/bin/javac
I found the correct location of the files by doing an
rpm -q -l jre-1.5.0_02-fcs|more and paging though until I saw what I was looking for
I am using Head first Java to learn. It's a fun book, in a very different style than a traditional tech book.
I found it lacking in the most basic stuf, how to actually run a program
Here is what I found out that was not in the book (besides the stuff about the broken symlinks.
- Each public class must be declared in a file with the same name as the class. (case counts)
public class MyFirstApp {
public static void main (String[] args){
System.out.print("I Rule");
}
}
Must be in a file named MyFirstApp.java
- To compile a file you type javac MyFirstApp.java
- This creates
MyFirstApp.class
- To RUN the file you type java MyFirstApp (NOTE THE ABSENCE OF THE .class)
It just would have been nice if somebody told me that. Instead I waisted time like this$ java MyFirstApp.class
Exception in thread "main" java.lang.NoClassDefFoundError: MyFirstApp/class
What the hell kind of error message is that ?
I mean with C it's gcc hello.c, which creates a.out (which is another issue for another time ;-) ) and to run the file it's ./a.out nobody assumes the extention for you. It just would have been nice if somebody told me this.
Replys:
|
|