How come this program doesnt run?

Reply

Join Date: Dec 2008
Posts: 65
Reputation: StarZ is an unknown quantity at this point 
Solved Threads: 1
StarZ StarZ is offline Offline
Junior Poster in Training

How come this program doesnt run?

 
0
  #1
Oct 6th, 2009
How come this program doesn't run?
Well.. not just this program, all my other ones.
There are no mistakes, I wrote the code as this textbook says but its not running and its giving this error (on dr java):

1 error found:
File: (no associated file) [line: (no source location)]
Error: No compiler is available.

The code looks like this:
  1. public class TestDisk {
  2.  
  3. public static void main(String[] args) {
  4. Disk saucer = new Disk(10, 0.02);
  5.  
  6. System.out.println("Disk radius: " + saucer.getRadius());
  7. System.out.println("Disk surface area: " + saucer.area());
  8. System.out.println("Disk volumn: " + saucer.volumn());
  9.  
  10. Disk plate1 = new Disk(12, 0.05);
  11. Disk plate2 = new Disk(12, 0.07);
  12. if (plate1.equals(plate2)) {
  13. System.out.println("objects are equal ");
  14. } else {
  15. System.out.println("Objects are not equal ");
  16. }
  17. System.out.println(plate1);
  18. System.out.println(plate2);
  19. }
  20. }

I saved it as Test.Disk
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 455
Reputation: Grn Xtrm is on a distinguished road 
Solved Threads: 36
Grn Xtrm's Avatar
Grn Xtrm Grn Xtrm is offline Offline
Posting Pro in Training
 
0
  #2
Oct 6th, 2009
The name of the file should be the name of the class in an example like this one. Save your file as TestDisk.java
Did you mean to put the '.' in between Test and Disk?
Last edited by Grn Xtrm; Oct 6th, 2009 at 6:20 pm.
Check out my new band URL on facebook. I'm the bass player. :) Become a fan and leave comments if you like.
URL on facebook!
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 65
Reputation: StarZ is an unknown quantity at this point 
Solved Threads: 1
StarZ StarZ is offline Offline
Junior Poster in Training
 
0
  #3
Oct 6th, 2009
Yea it is. accept on the top bar it says C://document and settings\HP_adminstrator\MyDocuments\TestDisk.java.. and it doesn't just say testDisk.java
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 455
Reputation: Grn Xtrm is on a distinguished road 
Solved Threads: 36
Grn Xtrm's Avatar
Grn Xtrm Grn Xtrm is offline Offline
Posting Pro in Training
 
1
  #4
Oct 6th, 2009
Do you have the java compiler downloaded? When I first started Java I had trouble finding the compiler online (i think it was called JDK or something like that). You need this to run java code and I dont believe it comes with Java implementation environments such as Jcreator, TextPad, etc.
Check out my new band URL on facebook. I'm the bass player. :) Become a fan and leave comments if you like.
URL on facebook!
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 65
Reputation: StarZ is an unknown quantity at this point 
Solved Threads: 1
StarZ StarZ is offline Offline
Junior Poster in Training
 
0
  #5
Oct 6th, 2009
oh, thats probably why.... I only dled the Dr java. Ima dl the JDK then
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 455
Reputation: Grn Xtrm is on a distinguished road 
Solved Threads: 36
Grn Xtrm's Avatar
Grn Xtrm Grn Xtrm is offline Offline
Posting Pro in Training
 
1
  #6
Oct 6th, 2009
Read this if you have trouble finding the compiler or have any other questions
http://www.daniweb.com/forums/thread99132.html#
Check out my new band URL on facebook. I'm the bass player. :) Become a fan and leave comments if you like.
URL on facebook!
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 65
Reputation: StarZ is an unknown quantity at this point 
Solved Threads: 1
StarZ StarZ is offline Offline
Junior Poster in Training
 
0
  #7
Oct 6th, 2009
I have dled the JDK.
Now I have Jdk and Drjava.
But now when I try to run this program there like like 14 errors.......
I don't get it..
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 455
Reputation: Grn Xtrm is on a distinguished road 
Solved Threads: 36
Grn Xtrm's Avatar
Grn Xtrm Grn Xtrm is offline Offline
Posting Pro in Training
 
0
  #8
Oct 6th, 2009
Originally Posted by StarZ View Post
I have dled the JDK.
Now I have Jdk and Drjava.
But now when I try to run this program there like like 14 errors.......
I don't get it..
Let us see the errors.
The class in which the Disk constructor is defined must be in the same folder/directory as the TestDisk class.
You do have a file with the Disk constructor right?... Or did you actually just copy that one part out of your book?
Last edited by Grn Xtrm; Oct 6th, 2009 at 7:35 pm.
Check out my new band URL on facebook. I'm the bass player. :) Become a fan and leave comments if you like.
URL on facebook!
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 14
Reputation: 0805638 is an unknown quantity at this point 
Solved Threads: 0
0805638 0805638 is offline Offline
Newbie Poster

My Second Post

 
0
  #9
Oct 6th, 2009
Some things you may wish to consider,
"Disk", can I see source of it?
"Disk"s constructor...is it expecting an integer then a double?
if (plate1.equals(plate2))...did you programme "equals" In Disk?
instead of printing plate1 try printing the plate1.toString which you should have programmed to simplify things

any corrections of my post pm me please
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 20
Reputation: Teethous is an unknown quantity at this point 
Solved Threads: 0
Teethous Teethous is offline Offline
Newbie Poster
 
0
  #10
Oct 6th, 2009
Let us see the "class file".
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC