• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Mac/Windows difference

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
lowercase baba
Posts: 13002
66
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bingo! I told you it was really basic....
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic