Results 1 to 7 of 7
  1. #1
    BlitzA is offline Member
    Join Date
    Dec 2007
    Posts
    11
    Rep Power
    0

    Default Help with setting up please

    I still need some help getting the Elements package working with java.

    I've typed this in command prompt:

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

    Java 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:

    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

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    758
    Rep Power
    8

    Default

    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:

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

  3. #3
    BlitzA is offline Member
    Join Date
    Dec 2007
    Posts
    11
    Rep Power
    0

    Default

    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:

    Java 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 08:51 PM.

  4. #4
    spoon! is offline Member
    Join Date
    Dec 2007
    Posts
    12
    Rep Power
    0

    Default

    Quote Originally Posted by BlitzA View Post
    What exactally does adding "." do then?
    . = current directory

  5. #5
    BlitzA is offline Member
    Join Date
    Dec 2007
    Posts
    11
    Rep Power
    0

    Default

    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 12:39 AM. Reason: adding content without double posting?

  6. #6
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    758
    Rep Power
    8

    Default

    I am a bit confused for the above message, can you explain more clearly what you wanted to do?

  7. #7
    BlitzA is offline Member
    Join Date
    Dec 2007
    Posts
    11
    Rep Power
    0

    Default

    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:

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

Similar Threads

  1. Setting the DSN
    By tim in forum JDBC
    Replies: 1
    Last Post: 02-14-2008, 09:55 PM
  2. JTextArea setting
    By newtojava7 in forum New To Java
    Replies: 1
    Last Post: 01-29-2008, 02:57 AM
  3. Help with setting up Java
    By itmasterw in forum New To Java
    Replies: 6
    Last Post: 01-18-2008, 11:04 PM
  4. Setting cookies in JSP
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-10-2007, 05:33 PM
  5. Setting currency
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-16-2007, 02:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •