• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mac/Windows difference

 
Stephen Bloch
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote up a sample program for my students (it's a JFrame, with SwingUtilities.invokeLater and an anonymous inner class, none of which I think is actually relevant to this question).

It compiles and runs under BlueJ, on both Mac and Windows. It compiles and runs from the command line on the Mac. It compiles from the command line on Windows, but when I try to run it, I get a NoClassDefFound exception on the main class.

Are there common reasons that this kind of thing would happen? (For example, spaces in a directory name on Windows?)
 
Stephen Bloch
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, this is much more basic than I thought. I thought the difficulty might have something to do with the constructor, the anonymous inner class, maybe the cases in the class name... so I reduced the program to



and I'm still having the problem: it compiles and runs fine under BlueJ, it compiles and runs fine on the Mac command line, it compiles but doesn't run on the Windows command line.

I hate Windows....I hate Windows....I hate Windows....I hate Windows....
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12098
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do you have a classpath environment variable set?

try running this from the directory where your .class files are

java -cp . <YourClassName>
 
Stephen Bloch
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bingo! I told you it was really basic....
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not export your sample program as a JAR so that you don't have to fiddle with the environment variables on all your students' machines?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Stephen Bloch:
I hate Windows....I hate Windows....I hate Windows....I hate Windows....

This error has nothing to do with Windows, and if you would have set the environment variable CLASSPATH on the Mac, you would have gotten exactly the same error on the Mac... Java = Java, doesn't matter on which operating system you run it.
[ June 19, 2006: Message edited by: Jesper Young ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic