English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

OK... i have some programs. I have a java compiler called Jcreator LE. I want to get it on my webpage. Is it suppose to be a class file that I upload? What do i have to add the the ".java" file so it can be like an applet... like do i have to put the extends to JApplet kind of thing. I basically have a .java program, and i want to get it on the web, how?
The program has the format of something like this, but a bit more complex:


public class hi
{
public static void main (String args[])
{
System.out.println("Hi");
}
}



So how do i get this online?

2006-07-14 11:41:19 · 3 answers · asked by Charles 2 in Computers & Internet Programming & Design

3 answers

In order to have your program on a webpage, you need to write your program as an applet. An applet does not use System commands or a main method. An applet version of your program would be like this...

import java.awt.*;
import java.applet.*;

public class hi extends Applet
{
Label myLabel = new Label("Hi");

public void init()
{
add(myLabel);
}
}

You also will need to add this code into the body of your html file...

2006-07-14 14:26:18 · answer #1 · answered by GreaseMonkeySteve 2 · 0 0

What you have given as an example is a java program NOT an applet.

Your java program can not be run on the internet.

To run an applet you need to have a java byte code file. You do this by coding an applet. Then you selecting Build and then Compile File. You now need to transfer the compiled byte code file to your internet domain. You will also need html code that points to the java byte code. This html file can be local to your computer or if the world is to access it should also be transfered to your domain.

Now use your browser to access your html file and you are done.

2006-07-14 19:08:41 · answer #2 · answered by AnalProgrammer 7 · 0 0

The answer should be here:
http://www.google.com/search?q=java+applet+tutorials

There are some examples on this site:
http://www.dgp.toronto.edu/~mjmcguff/learn/java/01-drawingLines/

2006-07-14 18:48:30 · answer #3 · answered by linuxfortravelers 3 · 0 0

fedest.com, questions and answers