Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

beginning java

Status
Not open for further replies.

dummie2

MIS
Mar 28, 2000
15
US
i compiled this program and it worked fine;<br><br>import java.awt.Graphics;<br><br>public class FirstApplet extends java.applet.Applet<br>{<br><br>&nbsp;&nbsp;&nbsp;&nbsp;public void paint(Graphics g)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g.drawLine(0, 0, 200, 200);<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br><br>then i tried to compile this one;<br><br>import java.awt.Graphics;<br><br>public class FirstApplet extends java.applet.Applet<br>{<br><br>&nbsp;&nbsp;&nbsp;&nbsp;public void paint(Graphics g)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int y;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;y = 10;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while (y &lt;= 210)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g.drawLine(10, y, 210, y);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;y = y + 25;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br><br>and i get a reply i the ms dos<br><br>'Jloop.java:3: Public class FirstApplet must be defined in a file called &quot;FirstApplet.java&quot;.<br>public class FirstApplet extends java.applet.Applet'<br><br>can n e one tell me what i did differently then the first one to why i'm getting this error message?<br><br>thank-u<br><br> <br><br><br>
 
The differe is the filename. I think you written the first into the FirstApplet.java, and the second FirstApplet2.java for example. But in java, if you write public class, the holder source file name must be the same with the class name. In the second the class name must be FirstApplet2.<br><br>Good luck. Bye, Otto.<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top