• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

probably a knucklehead question but...

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got it sorted out : And welcome to JavaRanch.
reply
    Bookmark Topic Watch Topic
  • New Topic