Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Java Help

Java Help
Thread Tools
turboSPE
Dedicated MacNNer
Join Date: Feb 2002
Location: Dallas
Status: Offline
Reply With Quote
Jan 19, 2004, 01:46 AM
 
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
     
rchang713
Fresh-Faced Recruit
Join Date: Nov 2002
Status: Offline
Reply With Quote
Jan 19, 2004, 03:48 AM
 
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.
     
turboSPE  (op)
Dedicated MacNNer
Join Date: Feb 2002
Location: Dallas
Status: Offline
Reply With Quote
Jan 19, 2004, 02:04 PM
 
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 Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 05:37 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,