aspose file tools*
The moose likes Mac OS and the fly likes How do I do this? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Mac OS
Bookmark "How do I do this?" Watch "How do I do this?" New topic
Author

How do I do this?

George Is Lost
Greenhorn

Joined: Jul 25, 2003
Posts: 1
This is very basic, but without it, I can't do a thing.
I want to do simple programming in Java (ie exercises out of a teach yourself book).
I know how (thankfully) to use a text editor to save text as a text file.
But, where do I save it when I'm asked?
How do I access javac to compile the text file?
Where does the resulting class file go?
How do I run the class file.
I have a Powerbook with MacOS X now.
I know how to do the above with MSDOS.
Thanks,
George Chen
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
I don't really understand the question.
Save the .java file to any directory you want. In the unix shell, cd to that directory and type "javac Foo.java" (replacing "Foo" by the name of your class). If the compile succeeds, it will create a file called "Foo.class". To run it, type "java Foo".
Make sure that your CLASSPATH environment variable includes ".", which means "the current directory."
If the class is in a package, or the file contains more than one class, things get a bit more complicated, but let's not go there yet.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
Welcome to JavaRanch George. Have you got it working yet?
Just a another little detail...
Your display name doesn't quite fit the famous JavaRanch naming policy. Could you please take a minute to change your display name to show 2 names, preferably your real name. (It's all about maintaining our professional image - don't let the one-eyed moose fool you!).
Thanks and hope you'll be visiting the ranch often,
Pauline
Pauline McNamara
Sheriff

Joined: Jan 19, 2001
Posts: 4012
    
    6
Originally posted by Ron Newman:

Make sure that your CLASSPATH environment variable includes ".", which means "the current directory."

I'm not sure this is always necessary, if you cd to the directory where your .java file is, or specify the path of the file when you compile it. I've been able to compile certain programs without setting CLASSPATH...
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
I think that not having a CLASSPATH is equivalent to having a CLASSPATH of ".", but if you have a CLASSPATH, it needs to explictly include "."
I could be wrong on this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do I do this?
 
Similar Threads
writing jpg/gif to rtf
Stream classes
In JFileDialog how to use the save window
save with JFileChooser
save random numbers