Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Sep 28, 2004, 06:00 PM   #1
Zion Grail
macrumors regular
 
Join Date: Dec 2002
Location: Chicagoland
Send a message via AIM to Zion Grail
Java trouble

Ever since I got the Java update I can't seem to run any of my classwork Java programs. No matter what I do, I get this error:

Exception in thread "main" java.lang.NoClassDefFoundError

Even in a simple HelloWorld! program I get this error. All of my programs, even ones that worked before, have started behaving like this.

Anyone else have this kind of problem?

*EDIT*

Even the ready-to-compile java files I got form the book's CD are acting like this!!
__________________
"Plan B always sucks."

Last edited by Zion Grail; Sep 28, 2004 at 06:06 PM.
Zion Grail is offline   0 Reply With Quote
Old Sep 28, 2004, 09:39 PM   #2
jeremy.king
macrumors 603
 
jeremy.king's Avatar
 
Join Date: Jul 2002
Location: Fox Lake, IL
How exactly are you trying to run these? Inside an IDE, from command line?

remember to compile your .java file first using javac and then run it with the java command (no extension on the file to be run)

For example
PHP Code:
public class HelloWorld
{
  public static 
void main(String[] args)
  {
    
System.out.println("I love my mac.");
  }

from terminal:

javac HelloWorld.java

this creates HelloWorld.class, and then

java HelloWorld

If this is completely obvious, I apologize, but every once and a while I brainfart and run the .java file through the java command and whoopsy...same problem

Good Luck
jeremy.king is offline   0 Reply With Quote
Old Sep 28, 2004, 10:00 PM   #3
King Cobra
Guest
 
Join Date: Mar 2002
Send a message via AIM to King Cobra
http://www.apple.com/downloads/macosx/apple/

If you're not running the latest version of Java, do that. There are Java 1.4.2 Update 2 and Update 1 links there. If those don't help, go through pages 2, 3, 4, etc. at the bottom of the page of the link above to find the Java 1.4.1 update (for Panther).
King Cobra is offline   0 Reply With Quote
Old Oct 7, 2004, 11:06 AM   #4
TEG
macrumors 604
 
TEG's Avatar
 
Join Date: Jan 2002
Location: Langley, Washington
Send a message via ICQ to TEG Send a message via AIM to TEG Send a message via MSN to TEG Send a message via Yahoo to TEG Send a message via Skype™ to TEG
That is how he got the problem, the update caused It. I've been having a similar problem when compiling. However, no problems with exitsting java apps. I'm just hoping Apple can get Java 5.0 (1.5) out quickly.

TEG
__________________
Apple and Dell are the only ones in this industry making money. They make it by being Wal-Mart. We make it by innovation, - Steve Jobs
The Tegian Zone-Glass Onion Radio
TEG is offline   0 Reply With Quote
Old Oct 7, 2004, 12:01 PM   #5
Zion Grail
Thread Starter
macrumors regular
 
Join Date: Dec 2002
Location: Chicagoland
Send a message via AIM to Zion Grail
Fixed it, somewhat

I can't be sure if it's the update or what, but I've found the problem - my classpath is blank. Nothin' in there. Gone.

I had to find where Java keeps it's classes on my system and manually set it, and I have to tell my system to inclde whatever current directory I've put my projects in my going to the command line, going to the directory i'm using, and typing

export CLASSPATH=$CLASSPATH:.

Then, to run anything in that directly, I *STILL* need to use the command

java -cp $CLASSPATH:. InsertClassNameHere

Then it works.

This is damn annoying, Apple. How did such a huge mistake get by you?
__________________
"Plan B always sucks."
Zion Grail is offline   0 Reply With Quote
Old Oct 7, 2004, 12:33 PM   #6
jeremy.king
macrumors 603
 
jeremy.king's Avatar
 
Join Date: Jul 2002
Location: Fox Lake, IL
Quote:
Originally Posted by Zion Grail
I can't be sure if it's the update or what, but I've found the problem - my classpath is blank. Nothin' in there. Gone.

I had to find where Java keeps it's classes on my system and manually set it, and I have to tell my system to inclde whatever current directory I've put my projects in my going to the command line, going to the directory i'm using, and typing

export CLASSPATH=$CLASSPATH:.

Then, to run anything in that directly, I *STILL* need to use the command

java -cp $CLASSPATH:. InsertClassNameHere

Then it works.

This is damn annoying, Apple. How did such a huge mistake get by you?
You need to set your CLASSPATH. Its not Apples responsibility. If you want it to be more permanant, look into editing the appropriate .rc file associated with your shell. If you are using bash then modify the .bashrc in your home directory. If you are using tcsh then you will modify your .tcshrc file. Add that export command to either file and it will automatically get set when you log in.

Edit: I think you have to use the setenv command instead of export. So your command should look like

setenv CLASSPATH .:$CLASSPATH

Last edited by jeremy.king; Oct 7, 2004 at 12:37 PM.
jeremy.king is offline   0 Reply With Quote
Old Oct 7, 2004, 12:33 PM   #7
bousozoku
Moderator emeritus
 
Join Date: Jun 2002
Location: Gone but not forgotten.
Quote:
Originally Posted by TEG
That is how he got the problem, the update caused It. I've been having a similar problem when compiling. However, no problems with exitsting java apps. I'm just hoping Apple can get Java 5.0 (1.5) out quickly.

TEG
It's not surprising. There was also an issue when they revised to 1.4 and they eventually got a developer tools update together which took care of the problem. If you look at downloads for tools on the Apple developer site, you'll find the update in 2003.

Hopefully, they'll be swift about it.
bousozoku is offline   0 Reply With Quote
Old Oct 7, 2004, 02:40 PM   #8
Zion Grail
Thread Starter
macrumors regular
 
Join Date: Dec 2002
Location: Chicagoland
Send a message via AIM to Zion Grail
Quote:
Originally Posted by kingjr3
You need to set your CLASSPATH. Its not Apples responsibility. If you want it to be more permanant, look into editing the appropriate .rc file associated with your shell. If you are using bash then modify the .bashrc in your home directory. If you are using tcsh then you will modify your .tcshrc file. Add that export command to either file and it will automatically get set when you log in.

Edit: I think you have to use the setenv command instead of export. So your command should look like

setenv CLASSPATH .:$CLASSPATH
When I was running 10.2, it was already set and all I needed was the "java" and "javac" commands. If they did it before, I'd expect Panther to have it set up as well.
__________________
"Plan B always sucks."
Zion Grail is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting 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

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Java Applet not working on Lion jake4ever Mac OS X 10.7 Lion 19 Feb 1, 2013 09:44 AM
"No compatible version of java 1.5+" when opening TinyUmbrella PSpfano OS X 3 Mar 31, 2011 12:37 PM
Using accessors in Java constructors (marc) Mac Programming 4 Dec 3, 2010 09:37 AM
Small Java Problem finnschi Mac Programming 9 Nov 25, 2010 04:26 PM
Java Troubles :( Maleficum Mac Programming 3 Nov 13, 2006 09:26 PM


All times are GMT -5. The time now is 03:59 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC