Results 1 to 7 of 7

Thread: Can't Compile?

  1. #1

    Thread Starter
    Addicted Member Ramandeep's Avatar
    Join Date
    Feb 2000
    Posts
    158

    Unhappy

    Hi, I have just recently started studying Java and therfore not to sure about solving these problems because the whole language is pretty strange to me (it’s the ugliest language I’ve come across so far!!!), any way the thing is when I try to compile my program I get the following error:

    'Exception in thread "main" Java.lang.NoClassDefFoundError: Welcome1/Class'

    I usually run them at uni and have no problem but I have just downloaded J2SDK from sun's web site and installed it and that's the error I get. Am I missing something? Any help would be appreciated

    !!!THANKS IN ADVANCE!!!

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    What package did you put it in? Did you try and run using just

    java Welcome1
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Guest
    Basically, for an app, it's like this:

    create/edit:
    YourClass.java

    public class YourClass{
    public static void main(String[] args){
    System.out.println("YourClass app ran");
    }
    }

    compile with:
    javac YourClass.java

    run with:
    java YourClass

  4. #4

    Thread Starter
    Addicted Member Ramandeep's Avatar
    Join Date
    Feb 2000
    Posts
    158
    parksie what do you mean what package did I put it in. I just install the J2SDK 1.3 on c:\

    when I compile I go to DOS Prompt and enter

    'C:\jdk1.3\bin> javac c:\welcome.java'

    This is right isn't it?

    Then when I run I do

    'C:\jdk1.3\bin> java c:\welcome.java'

    or

    'C:\>java welcome.class'

    Another thing VirtuallyVB has put '[]' after the String part in void main method but in my book they appeare after args, is there a difference?

  5. #5

    Thread Starter
    Addicted Member Ramandeep's Avatar
    Join Date
    Feb 2000
    Posts
    158
    Never mind guys I fixed it, I created a jdk.bat file to execute the following

    Set path=%path%;C:\jdk1.3\bin
    Set classpath=%classpath%;.

    Now I can more or less call/run the files from anywhere and they compile and execute OK.

    !!!THANKS FOR YOUR HELP ANYWAY GUYS!!!

  6. #6
    Guest
    When you run the application, parkie's and my point was that you DO NOT use a file extension.

    'C:\jdk1.3\bin> java c:\welcome'

    or

    'C:\>java welcome'

    java(.exe) actually references welcome.class when you do this.

    In the main method, you can have (String anyName[])
    or (String[] anyName)

    Packages are slightly more advanced, but you do have to understand paths for that.

  7. #7
    Lively Member Adrian Koh's Avatar
    Join Date
    Jan 2001
    Location
    Johor, Malaysia
    Posts
    64

    Hello

    Hello
    VisualBasic5.0ServicePack3

Posting Permissions

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



Click Here to Expand Forum to Full Width