| | |
Problems with compiling
![]() |
•
•
Join Date: Sep 2004
Posts: 11
Reputation:
Solved Threads: 0
Hi, ive only started to program in Java for the last couple of days. I picked up a disk containing JDK 1.3 from my uni so that I can compile programs at home.
I typed up this very simple program which is shown below
public class Hello
{
public static void main(String[] args)
{ System.out.print("Hello you");
}
}
When I tried compiling it I get this
C:\Documents and Settings\Owner>javac Hello.java
error: cannot read: Hello.java
1 error
C:\Documents and Settings\Owner>java Hello
Exception in thread "main" java.lang.NoClassDefFoundError: Hello
I dont know whether theres a problem with the program which i'm pretty sure is OK, the disk or even my PC. If anyone can explain to me what 'Exception in thread "main" java.lang.NoClassDefFoundError: Hello' means I will really appreciate it.
Thanks.
Mus.
I typed up this very simple program which is shown below
public class Hello
{
public static void main(String[] args)
{ System.out.print("Hello you");
}
}
When I tried compiling it I get this
C:\Documents and Settings\Owner>javac Hello.java
error: cannot read: Hello.java
1 error
C:\Documents and Settings\Owner>java Hello
Exception in thread "main" java.lang.NoClassDefFoundError: Hello
I dont know whether theres a problem with the program which i'm pretty sure is OK, the disk or even my PC. If anyone can explain to me what 'Exception in thread "main" java.lang.NoClassDefFoundError: Hello' means I will really appreciate it.
Thanks.
Mus.
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
What I really meant was that did you open the directory where the program was saved before trying to compile.
Example:
If you saved the program in C:/javawork
but if you are at the command line and and it says C:/documents and settings....blah blah it wont compile because thats not were the file was saved.
If you try to do this you'll get an error that says: error cannot read: Example.java
1 error
Im sure this is your problem because your error message is the same as above.
To fix this you need to:
at the command line type in: cd \DirectoryWereYouSavedTheJavaProgram
Then try to compile, and that should fix all your problems.
You posted that you tried this: C:\Documents and Settings\Owner>javac Hello.java
This is saying that your program is saved in C:\Documents and Settings\Owner but i dont know if you save your programs there or not.
I hope I was able to explain this good enough, I know it sounds confusing.
If the problem persists or if you are unclear on directions let me know.
Example:
If you saved the program in C:/javawork
but if you are at the command line and and it says C:/documents and settings....blah blah it wont compile because thats not were the file was saved.
If you try to do this you'll get an error that says: error cannot read: Example.java
1 error
Im sure this is your problem because your error message is the same as above.
To fix this you need to:
at the command line type in: cd \DirectoryWereYouSavedTheJavaProgram
Then try to compile, and that should fix all your problems.
You posted that you tried this: C:\Documents and Settings\Owner>javac Hello.java
This is saying that your program is saved in C:\Documents and Settings\Owner but i dont know if you save your programs there or not.
I hope I was able to explain this good enough, I know it sounds confusing.
If the problem persists or if you are unclear on directions let me know.
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
•
•
•
•
Originally Posted by Phaelax
System.out.print("Hello you");
I believe what you want is println() and not print()
he shouldn't have to set the classpath, as i believe it's done when the sdk is installed.
Also I had to manually set the classpath when I installed the sdk, so it cant always be set correctly when its installed.
![]() |
Similar Threads
- problems compiling first Windows application (C#)
- Compiling problem (C++)
- Hibernation/Suspend problems in Ubuntu Feisty (*nix Software)
- Some problems while compiling unidrv with another library (C++)
Other Threads in the Java Forum
- Previous Thread: WindowListener
- Next Thread: user input and search
| Thread Tools | Search this Thread |
-xlint actionlistener android api applet application array arrays automation bi binary blackberry block bluetooth character chat class client code compile compiler component consumer database desktop developmenthelp eclipse error fractal freeze ftp game gameprogramming givemetehcodez graphics gui html ide image integer j2me j2seprojects java javac javaee javaprojects jetbrains jni jpanel jtable julia learningresources lego linked linux list loops mac map method methods mobile netbeans newbie notdisplaying number online printf problem program programming project properties qt recursion researchinmotion rotatetext rsa scanner screen server set singleton sms sort sql string swing system textfields threads time title tree tutorial-sample update variablebinding windows working xor







