View previous topic :: View next topic |
Author |
Message |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Thu Nov 20, 2003 6:26 pm Post subject: Running Java Applets |
|
|
Hey aprelium I just tried testing your web server on a java applet and it does not seem to want to run , can you explain to me how to get it to work , the code is posted below.
HelloWorld.class
Code: | /*
By Bavo Bruylandt (Http://www.realapplets.com")
*/
// and now The inevidable "Hello World" example :)
// tell the compiler where to find the methods you will use.
// required when you create an applet
import java.applet.*;
// required to paint on screen
import java.awt.*;
// the start of an applet - HelloWorld will be the executable class
// Extends applet means that you will build the code on the standard Applet class
public class HelloWorld extends Applet
{
// The method that will be automatically called when the applet is started
public void init()
{
// It is required but does not need anything.
}
// This method gets called when the applet is terminated
// That's when the user goes to another page or exits the browser.
public void stop()
{
// no actions needed here now.
}
// The standard method that you have to use to paint things on screen
// This overrides the empty Applet method, you can't called it "display" for example.
public void paint(Graphics g)
{
//method to draw text on screen
// String first, then x and y coordinate.
g.drawString("Hellow World",20,40);
}
}
|
The HTML code for it
Code: | <applet code="HelloWorld.class" width="200" height="50"></applet> |
HelloWorld.class is inside my normal htdocs folder so it doesn't matter about the path , I set it all up the correct way so please hep me figure this out. |
|
Back to top |
|
 |
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
Posted: Thu Nov 20, 2003 9:20 pm Post subject: |
|
|
Might be a silly question but you do know you have to use the compiled version that right? You don't put just put that code in a file in the directory and expect it to run... _________________
"Invent an idiot proof webserver and they'll invent a better idiot..." |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Thu Nov 20, 2003 10:11 pm Post subject: |
|
|
Well im a Noob at java and to me java sucks on abyss web server so I would like to know how the hell to configure abyss for java applets , I can view applets i just can't get them to run on abyss. Please help me! :( |
|
Back to top |
|
 |
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
Posted: Thu Nov 20, 2003 10:55 pm Post subject: |
|
|
I think you're confusing client side and server side java applets - the hello world applet would be run in the viewers browser, not on the webserver, so it makes no difference what server you use.
Server side javascript is a whole different kettle of fish. http://www.javaworld.com/javaworld/jw-03-1997/jw-03-ssj.html explains server side java better than I could :) Aprelium don't mention Abyss supporting it so you'd have to wait for their reply on this one. |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Thu Nov 20, 2003 11:21 pm Post subject: |
|
|
Ok Anonymoose , why don't you copy the code I posted above and create a html page and let me see if it loads on your abyss web server. Please do that so i know that im not stupid. |
|
Back to top |
|
 |
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
Posted: Thu Nov 20, 2003 11:31 pm Post subject: |
|
|
That's what I was trying to say - you don't just copy that code above, you have to compile it into a class file, then you embed the class file in the page. The browser downloads the class and executes it using the java virtual machine on the client PC. |
|
Back to top |
|
 |
olly86 -
Joined: 25 Apr 2003 Posts: 993 Location: Wiltshire, UK
|
Posted: Thu Nov 20, 2003 11:34 pm Post subject: |
|
|
TRUSTpunk wrote: | why don't you copy the code I posted above and create a html page and let me see if it loads on your abyss web |
i've just tested it and i can only get 'invalid bytecode' _________________ Olly |
|
Back to top |
|
 |
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
Posted: Thu Nov 20, 2003 11:41 pm Post subject: |
|
|
http://javaboutique.internet.com/tutorials/Thread0/add_java.html
Olly, you tried compiling it or you just pasted it into notepad and saved it as a class file ? You need to save that code into a file called HelloWorld.java then compile it. To compile it you need to install the Java SDK and a decent IDE if you're going to do any work on your own java and don't want to mess with the command line. Netbeans is ok but bulky if you're just going to compile little applets to run. You could give JCreator LE a whirl for this.
http://www.jcreator.com/
After doing the above and creating HelloWorld.class properly, yes, it is working fine on my server. All it is to the server is just another file; it doesn't run on the server. Remember that the filename for .class files is case sensitive and must match the internal name of the class. Java is fiddly 8O |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Fri Nov 21, 2003 12:43 am Post subject: |
|
|
Your right Anonymoose because I downloaded the working HelloWorld.class from the web site that had the hello world example and it was compiled , any good java compilers , I can't find Java SDK ? 8) |
|
Back to top |
|
 |
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Fri Nov 21, 2003 1:03 am Post subject: |
|
|
I just downloaded it and I don't see how to compile a .class file , can you explain here on the aprelium forum how to compile a .class file using the java(TM) 2 SDK |
|
Back to top |
|
 |
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
Posted: Fri Nov 21, 2003 1:47 am Post subject: |
|
|
Which one did you install, JCreator or Netbeans ?
Java's not something you'll get very far with if you're not going to work through the documentation/examples... Basically, copy the code you pasted into Notepad, save it as "HelloWorld.java" - use quotes in the save box to save it with a .java extension. Load it up in either of the IDEs, use Build->Compile in Netbeans or Build->Compile File in JCreator to make a .class file and then put the class file in htdocs/wherever and link to it in your HTML. |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
|
Back to top |
|
 |
Anonymoose -
Joined: 09 Sep 2003 Posts: 2192
|
Posted: Fri Nov 21, 2003 2:24 am Post subject: |
|
|
:D |
|
Back to top |
|
 |
|