Problems with compiling

Reply

Join Date: Sep 2004
Posts: 11
Reputation: mus_203 is an unknown quantity at this point 
Solved Threads: 0
mus_203 mus_203 is offline Offline
Newbie Poster

Problems with compiling

 
0
  #1
Oct 8th, 2004
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Problems with compiling

 
0
  #2
Oct 9th, 2004
Did you save the java file in the right directory? Also have you set the classpath and stuff like that?
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 11
Reputation: mus_203 is an unknown quantity at this point 
Solved Threads: 0
mus_203 mus_203 is offline Offline
Newbie Poster

Re: Problems with compiling

 
0
  #3
Oct 12th, 2004
Hi thanks for replying to my post about my problems with compiling. What do you mean about saving the java file in the right directory. I'm confused can you reply back please i will really appreciate it.

Thanks,
Mus
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Problems with compiling

 
0
  #4
Oct 12th, 2004
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 3
Reputation: jjohnson33 is an unknown quantity at this point 
Solved Threads: 0
jjohnson33 jjohnson33 is offline Offline
Newbie Poster

Re: Problems with compiling

 
0
  #5
Oct 12th, 2004
first create a folder on the root of the c: drive called Java or something of that nature. Move any applications you build there. Make sure you have edited the system path to include the jdk.

to compile :

c:\Doc~>cd C:\Java
c:\Java>javac Application.java

to run:
c:\Java>java Application
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 763
Reputation: Phaelax is on a distinguished road 
Solved Threads: 38
Phaelax Phaelax is offline Offline
Master Poster

Re: Problems with compiling

 
0
  #6
Oct 12th, 2004
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Problems with compiling

 
0
  #7
Oct 13th, 2004
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.
Since he's only got one line to print it won't make a diffrence if he uses print() over println().

Also I had to manually set the classpath when I installed the sdk, so it cant always be set correctly when its installed.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 11
Reputation: mus_203 is an unknown quantity at this point 
Solved Threads: 0
mus_203 mus_203 is offline Offline
Newbie Poster

Re: Problems with compiling

 
0
  #8
Oct 14th, 2004
Thanks a lot for your help I tried what you said and it works fine know.

Thanks again.
Mus
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 11
Reputation: mus_203 is an unknown quantity at this point 
Solved Threads: 0
mus_203 mus_203 is offline Offline
Newbie Poster

Re: Problems with compiling

 
0
  #9
Oct 14th, 2004
Thanks a lot for your help everything works now.
Thanks again.

Mus.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC