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 question...

java question...
Thread Tools
Dedicated MacNNer
Join Date: Feb 2001
Location: Manhattan
Status: Offline
Reply With Quote
Sep 8, 2002, 09:58 PM
 
so i've been teaching myself java and at work over the past few weeks have been playing with some code on the pc i work on. i downloaded the jdk and everything works as expected.

so i finally had free time at home (weird that i have the time at work and not home...women) so i wanted to play some with the code i've been working on and learning with. so just to make sure everything is working i type:

Code:
public class Hello { public static void main( String[] args ) { System.out.println("look at me..."); } }
...into vi and then compile it with "%javac Hello.java" and it compiles properly and then i go to run it with "%java Hello.class" and boom, i get this error:

Code:
Exception in thread "main" java.lang.NoClassDefFoundError: Hello/class
anyone know what this means? it's just a simple console app with no necessary libraries that i have to import...what gives? i recreated the file in project builder and figured it would attach any required files but i get the same error in the run dialog.

any insight would be appreciated...
thanks
amit
     
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Sep 8, 2002, 11:48 PM
 
It's looking for the class "Hello.class", like "java.lang.String". You just want the class "Hello", so you should do it like this:
Code:
% java Hello
It seems a little counterintuitive, I know, but that's how it works.
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
     
ameat  (op)
Dedicated MacNNer
Join Date: Feb 2001
Location: Manhattan
Status: Offline
Reply With Quote
Sep 9, 2002, 03:09 PM
 
Originally posted by Chuckit:
It's looking for the class "Hello.class", like "java.lang.String". You just want the class "Hello", so you should do it like this:
Code:
% java Hello
It seems a little counterintuitive, I know, but that's how it works.
great, thanks man. i thought i had tried that but it seems to be working now.
     
   
Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:46 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2