Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

c-Row

macrumors 65816
Original poster
Jan 10, 2006
1,193
1
Germany
I finally picked up my JAVA books again to get into the subject this year, but so far it's been more struggle than fun. I started with the easiest code listing one could imagine.

Code:
public class Hello
{  
  public static void main (String[] args)
  {
     System.out.println("Hello World!");
  }
}

It compiles fine (using "javac" in Terminal), but I can neither run the compiled class file in Finder nor via Terminal.

Even the examples from other websites (O'Reilly etc.) won't show any sign of life, although at least they give me an error message (Jar Launcher: The jar file "YaddaYadda.class" couldn't be launched. Chek the Console for possible error messages). Which isn't much of help at this point.

What could be wrong?
 

Sayer

macrumors 6502a
Jan 4, 2002
981
0
Austin, TX
Worked for me:

Code:
Jasmine:~ me$ javac Hello.java
Jasmine:~ me$ java Hello
Hello World!

You didn't provide any details on your setup e.g. what OS X version, which Java JDK you installed recently...
 

c-Row

macrumors 65816
Original poster
Jan 10, 2006
1,193
1
Germany
I'm on 10.5.1 but didn't install any additional files since I thought everything came in-the-box with OS X.
 

c-Row

macrumors 65816
Original poster
Jan 10, 2006
1,193
1
Germany
Why? Oh why? I just tested it once more, and it works fine!

:confused:

No idea what caused this in the first place, but now my class greets me as I deserve it. :D Thanks for your efforts!
 

afunsten

macrumors newbie
Feb 6, 2008
2
0
Works

If you exclude the .class extension on your class file is works! This is very counter intuitive. _Adam
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.