|
|
Java Help
|
|
|
|
Dedicated MacNNer
Join Date: Feb 2002
Location: Dallas
Status:
Offline
|
|
Hi everyone. I'm trying to compile the following code in Java on my Mac:
import javabook.*;
class TestJava
{
public static void main (String[] args)
{
//declare the MainWindow and the MessageBox
MainWindow mainWindow;
MessageBox messageBox;
//Create the MainWindow and the MessageBox
mainWindow = new MainWindow ("TestJava");
messageBox = new MessageBox (mainWindow);
//display MainWindow and the MessageBox
mainWindow.setVisible (true);
messageBox.show ("Your Java development environment has been setup successfully. ");
}
}
I've put a folder called "javabook" (no quotes) in my /Library/Java/Extensions folder, but to no avail (NoClassDefFound error). Can anybody help me? I guess I need to know where to put my .class files. Thanks!
turboSPE
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Nov 2002
Status:
Offline
|
|
Are you compiling from the terminal? If so you can then just set your classpath (telling javac where to look for classes) at compile time. If you put a javabook directory in your home directory, you should just be able to use: "javac -classpath /Users/yourName/ TestJava.java" You probably don't want to put all classes you'll ever be using in the system wide classpath location (I'm not sure where that is on OS X). If you're using an IDE there's going to be a way to set up your classpath for each project you start as well. This helps to avoid cluttering your system with class files you're only going to use a few times.
|
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Feb 2002
Location: Dallas
Status:
Offline
|
|
Originally posted by rchang713:
Are you compiling from the terminal? If so you can then just set your classpath (telling javac where to look for classes) at compile time. If you put a javabook directory in your home directory, you should just be able to use: "javac -classpath /Users/yourName/ TestJava.java" You probably don't want to put all classes you'll ever be using in the system wide classpath location (I'm not sure where that is on OS X). If you're using an IDE there's going to be a way to set up your classpath for each project you start as well. This helps to avoid cluttering your system with class files you're only going to use a few times.
That worked! Thanks for your help!
turboSPE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|