Results 1 to 7 of 7
Thread: Help with setting up please
- 12-28-2007, 02:53 PM #1
Member
- Join Date
- Dec 2007
- Posts
- 11
- Rep Power
- 0
Help with setting up please
I still need some help getting the Elements package working with java.
I've typed this in command prompt:
So now it let's me compile this code:Java Code:set CLASSPATH=C:\Program Files\Java\jdk1.6.0_03\bin\element.zip
So I get a file called DrawRect.classJava 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); } }
When I type in java DrawRect to run the code it says:
Java 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
- 12-28-2007, 03:56 PM #2
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
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:
or you can define the classpath when you execute the java command with -cp or -classpath option set.Java Code:set CLASSPATH=C:\Program Files\Java\jdk1.6.0_03\bin\element.zip;.
Website: Learn Java by Examples
- 12-28-2007, 08:48 PM #3
Member
- Join Date
- Dec 2007
- Posts
- 11
- Rep Power
- 0
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 08:51 PM.
- 12-28-2007, 11:41 PM #4
Member
- Join Date
- Dec 2007
- Posts
- 12
- Rep Power
- 0
- 12-28-2007, 11:56 PM #5
Member
- Join Date
- Dec 2007
- Posts
- 11
- Rep Power
- 0
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 12:39 AM. Reason: adding content without double posting?
- 12-29-2007, 02:12 AM #6
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
I am a bit confused for the above message, can you explain more clearly what you wanted to do?
Website: Learn Java by Examples
- 12-29-2007, 12:54 PM #7
Member
- Join Date
- Dec 2007
- Posts
- 11
- Rep Power
- 0
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:
what should I have done?Java Code:set CLASSPATH=C:\Program Files\Java\jdk1.6.0_03\bin\element.zip;.
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.
Similar Threads
-
Setting the DSN
By tim in forum JDBCReplies: 1Last Post: 02-14-2008, 09:55 PM -
JTextArea setting
By newtojava7 in forum New To JavaReplies: 1Last Post: 01-29-2008, 02:57 AM -
Help with setting up Java
By itmasterw in forum New To JavaReplies: 6Last Post: 01-18-2008, 11:04 PM -
Setting cookies in JSP
By Java Tip in forum Java TipReplies: 0Last Post: 12-10-2007, 05:33 PM -
Setting currency
By Java Tip in forum Java TipReplies: 0Last Post: 11-16-2007, 02:08 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks