• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

compilation error

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help. Your observations were right on.

Oldtimer
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic