• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

probably a knucklehead question but...

 
Patrick Burdine
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like many of the other beginners here, I am learning this through the Head First book. I am using a macbook Pro running OSX 10.6.5

when I run java -version I get 1.6.0_22 (from anywhere which makes me think it is in the path)

I write the basic code out in vi and then save it as a .java file (BeerSong.java for instance).

I can compile it with javac BeerSong.java which creates the class. But them I am not sure what to do. I get errors when I try and run %java BeerSong.java

The HF book shows that I should be typing %java but when I try the %java I get a message -bash: fg: %java: no such job.

Sorry for the basic question but I am pretty new to this, teaching myself through these books (started programming with HF Programming and getting into Python - thanks!)

Patrick

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not into Mac, but I'm not sure you need that "%". Try again without it and correct it to "java BeerSong", not "java BeerSong.java". You may have to make your class in the classpath. An easy way to do it is to go to the top package where your class is, and type "java -cp . BeerSong".

I'm not sure because I don7t have the book, but I guess that the "%" is just a symbol shown at the command prompt of the Unix terminal.
 
Patrick Burdine
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AH, that got it, thanks! I am used to having to add an extension when I run the file. I knew it was an easy one. Thanks!

The % thing I a bit odd, I kind of thought that too, but even in the plain text they show it. Ah well. Thanks again!

Patrick
 
Henry Wong
author
Marshal
Pie
Posts: 21024
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Patrick Burdine wrote:
The % thing I a bit odd, I kind of thought that too, but even in the plain text they show it. Ah well. Thanks again!


Of course, my fellow old-timers know that, on early versions of unix, using the original version of the bourne shell, and not setting a command prompt, and the user is not the super user, then the default prompt is "%".

Henry
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it sorted out : And welcome to JavaRanch.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic