Click to See Complete Forum and Search --> : Can't Compile?
Ramandeep
Feb 24th, 2001, 12:53 PM
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!!!
parksie
Feb 24th, 2001, 01:02 PM
What package did you put it in? Did you try and run using just
java Welcome1
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
Ramandeep
Feb 24th, 2001, 02:32 PM
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?
Ramandeep
Feb 24th, 2001, 03:33 PM
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!!!
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.
Adrian Koh
Mar 25th, 2001, 09:17 PM
Hello
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.