Kangry.com [insert cool graphic here]
home | Topics | Logout | Search | Contact | ?? Kangry ?? | Bandwitdh
Topics:
DVR
nvrec
Mplayer
Links
Misc
Commands
Humor

Name

Password

New user

uploaded files
(linux_command_line)-> java compile/run submited by Russell Mon 23 May 05
Edited Wed 11 Jan 06
Web kangry.com
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:
java tools (Russell)
Looking for the Head First Java book as a torrent ? (Russell)
Learning Java (Mike)

Add comment or question...:
Subject:
Submited by: NOT email address. Leave blank for anonymous    (Spam Policy)

Enter Text: (text must match image for posting)




This file (the script that presented the data, not the data itself) , last modified Tuesday 06th of March 2018 11:41:12 PM
your client: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
current time: Tuesday 23rd of April 2024 07:44:14 PM