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 Nov 5, 2009, 02:50 PM   #1
davidlt
macrumors member
 
Join Date: May 2007
Location: Lithuania
10.6 + JAVA = not working?

Okay, it is first time after 10.6 upgrade on 10.5 I used JAVA on this Mac. And it did not work. So I went Sun page for tutotial. Here is the program:
Code:
//A Very Simple Example
class ExampleProgram {
  public static void main(String[] args){
    System.out.println("I'm a Simple Program");
  }
}
Saved it to "ExampleProgram.java".

When:
javac ExampleProgram.java
java ExampleProgram

Got:
Exception in thread "main" java.lang.NoClassDefFoundError: ExampleProgram
Caused by: java.lang.ClassNotFoundException: ExampleProgram
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:330)
at java.lang.ClassLoader.loadClass(ClassLoader.java:254)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:399)

And it's the same for every JAVA program. What's wrong? Anyone see?
davidlt is offline   0 Reply With Quote
Old Nov 5, 2009, 03:33 PM   #2
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: Dallas, TX
worked fine for me on 10.6. Maybe try:
java -cp . ExampleProgram

to see if . isn't in your default classpath? I can't imagine why that would be.

Also, was ExampleProgram.class generated in your current directory?

-Lee
lee1210 is offline   0 Reply With Quote
Old Nov 5, 2009, 03:55 PM   #3
chown33
macrumors 603
 
Join Date: Aug 2009
Define your class as:

Code:
public class ExampleProgram {
It should work without public (and it does work here), but it's not a good idea.


Make sure you don't have a CLASSPATH environment variable defined. Execute this Terminal command:

Code:
printenv | sort
Copy and paste the output into a reply post.
chown33 is offline   0 Reply With Quote
Old Nov 5, 2009, 10:41 PM   #4
davidlt
Thread Starter
macrumors member
 
Join Date: May 2007
Location: Lithuania
a) "public" does not change anything.
b) Yeah, it looks I do have CLASSPATH set to CLASSPATH=/Users/david/.resolver somewhy.
c) java -cp . ExampleProgram works.

Yeah, it's a DocBook thing. Uninstalling DocBook fixed it.
davidlt 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
Youtube not working in Safari? Hyde244 Mac Applications and Mac App Store 12 Nov 16, 2011 11:12 PM
Firewall Preferences Not Saving After OS 10.6.6 Upgrade wildwell OS X 2 Jan 23, 2011 10:37 PM
Firewall Preferences Not Saving After OS 10.6.6 Upgrade wildwell OS X 0 Jan 13, 2011 11:33 AM
Do not upgrade to 10.6.5 if you use PGP wesker OS X 0 Nov 11, 2010 10:11 PM


All times are GMT -5. The time now is 04:38 PM.

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

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