|
|||||||
| Java (NOT JavaScript!) For discussion of the Java programming language as it applies to the Web ( Not JavaScript ). |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
applet help
hey guys hows it goin, finished with school now, and on my own i am learning applets. um now this might be a stupid question , but this isnt working for me, not sure whats up. how do i save a java text as a class file. cause im using this code and in the utorial, they show the target using a class file, not a .java file. not sure if it make a difference or not, so i used the file that it saved as(.Java).
can someone help ///////////////////////////////////////////////////////////////////// java file ///////////////////////////////////////////////////////////////////// import java.applet.Applet; import java.awt.Graphics; public class HelloWorld extends Applet { public void paint(Graphics g) { g.drawString("Hello world!", 50, 25); } } with this html <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>New Page 1</title> </head> <body> <applet code="file:///C:/Documents and Settings/Me/Desktop/Web/HTML Development/Java/Class'/test.java" WIDTH="150" HEIGHT="25"> </applet> </body> </html> but htis does not work, just gives me a grey box wit the target directory. any suggestions? |
|
#2
|
||||
|
||||
|
The code attribute has to point to compiled Java, either a class file or a jar or zip.
__________________
Help Save Ana Why use Web Standards: Zeldman How (new): Castro How (experienced): Cederholm If you can only get one book and you're already HTML savvy then this is it: stylin' with CSS: A Designer's Guide Charles Wyke-Smith New Riders "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Brian W. Kernighan |
|
#3
|
|||
|
|||
|
Your file should be named in referance to the name of the class. So rename your file HelloWorld.java and then use HelloWorld.class in the code attribute in your HTML.
__________________
http://www.andrewbuntine.com |
|
#4
|
|||
|
|||
|
yea i know buntin, it was a mistake on my part for that, even if i do that, it dont work
|
|
#5
|
|||
|
|||
|
Read this to get an overview of how Java Applets are supposed to be laid out: http://java.sun.com/docs/books/tutor...iew/index.html
Regards.
__________________
http://www.andrewbuntine.com |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|