Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-28-2007, 03:53 PM
Member
 
Join Date: Dec 2007
Posts: 11
BlitzA is on a distinguished road
Help with setting up please
I still need some help getting the Elements package working with java.

I've typed this in command prompt:

Code:
set CLASSPATH=C:\Program Files\Java\jdk1.6.0_03\bin\element.zip
So now it let's me compile this code:

Code:
import element.*; public class DrawRect { public static void main(String args[]) { DrawingWindow d = new DrawingWindow(); Rect cornerRect = new Rect(10,10,20,30); d.draw(cornerRect); } }
So I get a file called DrawRect.class

When I type in java DrawRect to run the code it says:

Code:
C:\Program Files\Java\jdk1.6.0_03\bin>java DrawRect Exception in thread "main" java.lang.NoClassDefFoundError: DrawRect

Someone please help I've been trying to get this working for hours and haven't even started my project lol
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-28-2007, 04:56 PM
Member
 
Join Date: Jun 2007
Location: Bali, ID
Posts: 90
wsaryada is on a distinguished road
The error says that it cannot found your DrawRect in the classpath. Basically adding a "." to the classpath solve the problem as you execute the class from inside the same folder. So try to update the classpath to:

Code:
set CLASSPATH=C:\Program Files\Java\jdk1.6.0_03\bin\element.zip;.
or you can define the classpath when you execute the java command with -cp or -classpath option set.
__________________
Website:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
- Blog:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-28-2007, 09:48 PM
Member
 
Join Date: Dec 2007
Posts: 11
BlitzA is on a distinguished road
Quote:
Originally Posted by wsaryada View Post
The error says that it cannot found your DrawRect in the classpath. Basically adding a "." to the classpath solve the problem as you execute the class from inside the same folder. So try to update the classpath to:

Code:
set CLASSPATH=C:\Program Files\Java\jdk1.6.0_03\bin\element.zip;.
or you can define the classpath when you execute the java command with -cp or -classpath option set.
Ah, excellent i'll try that when I get back from work.

What exactally does adding "." do then?

Can you explain classpath to me, I've kinda fumbled onto where i'm at now without really knowing what i'm doing.

I'm not meant to have things running from the bin folder either am I? ha.

Cheers bud.

edit: nice site in sig.

Last edited by BlitzA : 12-28-2007 at 09:51 PM.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 12-29-2007, 12:41 AM
Member
 
Join Date: Dec 2007
Posts: 12
spoon! is on a distinguished road
Quote:
Originally Posted by BlitzA View Post
What exactally does adding "." do then?
. = current directory
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 12-29-2007, 12:56 AM
Member
 
Join Date: Dec 2007
Posts: 11
BlitzA is on a distinguished road
Quote:
Originally Posted by spoon! View Post
. = current directory
Ah ok, so it's looking for my .class file DrawRect in element.zip?

And adding "." to the classpath makes it look in the right directory, as in the "bin" subdirectory.

So this must mean that my classpath needs sorting out.

How can I have it so it will use element.zip without making the classpath directly go there, which is what I was asking about the first time round basicly.

Hope you understand this.. cheers for help.. dunno if I'm being thick here or not but I just need to get my head around what's going on.

putting ;. worked, cheers

So what should I have done instead?

Last edited by BlitzA : 12-29-2007 at 01:39 AM. Reason: adding content without double posting?
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 12-29-2007, 03:12 AM
Member
 
Join Date: Jun 2007
Location: Bali, ID
Posts: 90
wsaryada is on a distinguished road
I am a bit confused for the above message, can you explain more clearly what you wanted to do?
__________________
Website:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
- Blog:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 12-29-2007, 01:54 PM
Member
 
Join Date: Dec 2007
Posts: 11
BlitzA is on a distinguished road
Quote:
Originally Posted by wsaryada View Post
I am a bit confused for the above message, can you explain more clearly what you wanted to do?
Apoligies for that.

What I was saying is that I now see that my classpath must be wrong, as I shouldn't be running things out of the same directory as my javac file.

Instead of putting:

Code:
set CLASSPATH=C:\Program Files\Java\jdk1.6.0_03\bin\element.zip;.
what should I have done?




Also on a side note, do you know how I can close DrawingWindow's in windows XP. At the moment I ctrl-alt-del then end task to close it.

If I'm changing code all the time this takes to long.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting the DSN tim Database 1 02-14-2008 10:55 PM
JTextArea setting newtojava7 New To Java 1 01-29-2008 03:57 AM
Help with setting up Java itmasterw New To Java 6 01-19-2008 12:04 AM
Setting cookies in JSP Java Tip Java Tips 0 12-10-2007 06:33 PM
Setting currency Java Tip Java Tips 0 11-16-2007 03:08 PM


All times are GMT +3. The time now is 11:08 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org