Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compilation error

 
Georgie Shmolowitz
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have written a program Nhisto3.java which consists of two classes:

import java.applet.* ;
import java.awt.* ;
import java.util.* ;
import java.lang.*;
import java.lang.Math.* ;
import java.awt.event.*;
public class NHisto3 extends DBufferApplet implements ActionListener, Runnable {
………
class DrawingCanvas extends Canvas {
………..
}
}
The compilation fails:

javac Nhisto3.java
Nhisto3.java:11: class NHisto3 is public, should be declared in a file named NHisto3.java
public class NHisto3 extends DBufferApplet implements ActionListener, Runnable {
^
Note: Nhisto3.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error

I am a tyro at Java and would appreciate some help.

BRS
 
Paul Clapham
Sheriff
Pie
Posts: 20713
30
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nosneb sunshine wrote:Nhisto3.java:11: class NHisto3 is public, should be declared in a file named NHisto3.java


I know this seems picky, but if you read the error message very carefully, you'll see that the filename you chose (Nhisto3.java) is not the same as the filename which the error message says should be used (NHisto3.java). Do you see the difference?
 
Tony Fu
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess your filename is not the same with your class name "Nhisto3".Your java filename should be "Nhisto3.java".
 
Georgie Shmolowitz
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your help. Your observations were right on.

Oldtimer
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic