File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes probably a knucklehead question but... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "probably a knucklehead question but..." Watch "probably a knucklehead question but..." New topic
Author

probably a knucklehead question but...

Patrick Burdine
Greenhorn

Joined: Nov 04, 2010
Posts: 2
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

Joined: Nov 24, 2005
Posts: 14688
    
  16

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.


[My Blog]
All roads lead to JavaRanch
Patrick Burdine
Greenhorn

Joined: Nov 04, 2010
Posts: 2
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
Sheriff

Joined: Sep 28, 2004
Posts: 19069
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Got it sorted out : And welcome to JavaRanch.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: probably a knucklehead question but...