• Post Reply Bookmark Topic Watch Topic
  • New Topic

Basic java setup  RSS feed

 
Tr Hatcher
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm hoping someone can help me with my intro to Java. I am on a Mac, OS X 10.7.5. I downloaded j7u9, and installed it and the runtime file. The original Java file in Library/Java is untouched. The downloaded file (1.6.0.jdk) is in System/Library/Java/JavaVirtualMachines. I have restarted the computer since those files were downloaded.

I went to Terminal and entered the javac command on a small file, with the following result:

rarhatcher:~ rarhatcher$ javac Party.java
javac: file not found: Party.java
Usage: javac <options> <source files>
use -help for a list of possible options
rarhatcher:~ rarhatcher$

I've previously had an error message to the effect that it didn't recognise the term 'javac'. I don't know whether I have made an error in the installations, if I am missing something that's required, or if I have the .java file in the wrong place.

I am only at the very beginning of working with Java, and have no idea what files are required. My textbook (I'm not in a class, I'm doing this on my own) says I need to download j2sdk and install it, but I can't find a download of that anywhere by that name. It appears it is contained in the SE files, but I don't actually know that.

I'm sure there's something basic I'm missing, but have no clue what it is. Can you help?
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

The fact that you're getting an error from javac shows that it's finding the javac executable OK, so it's not the path that's the problem.

What you need to provide is the classpath - this is where the compiler looks to find java files. The best way to do this is as a command-line option. So try this:

javac -cp . Party.java

That's assuming you're running this from the same folder as Party.java. '-cp .' says "look in the current folder".
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need to install anything. Max OS X comes with a Java implementation that will install itself on first use.

From your post, the javac command is working, so you should be fine. To be sure, enter javac -version, and if you don't get a command-not-found error, you're good to go.

Does the Party.java file exist in the folder when you execute the javac command?

[Edit: Matthew beat me to it!]
 
Tr Hatcher
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew and Bear,
Thanks so much for the info; it sounds good and I'll try it ASAP, but right now I'm getting ready for turkey day! I may be able to try on Sat or Sun, but either way, in case you like follow-up, I ll post to let you know how I did. Again, thanks! :-)
TR
 
Tr Hatcher
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Michael and Bear;
Just wanted to let you know I now have a working setup on both the Mac and the PC. My mistake was that I hadn't changed the directory in Terminal/Command Prompt to where my .java files were found. Once I did that, everything worked just fine. Thanks so much for your help!
 
Tr Hatcher
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthew, my apologies for the name mixup!
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tr Hatcher wrote:Matthew, my apologies for the name mixup!


No problem . And you're welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!