my last thread was just solved that i can run my java programs in my linux box.

now i would love to know if some one knows how to make a html/xml page that has a link that if i clicked and it would execute my java program.

all i want to know is how to make the link works to exe the java program. a quick simple example would be great. Thanks very much

You could have a hyperlink in an HTML page that links to another HTML page that contains a Java Applet. Not sure if that's what you are after though...

You could have a hyperlink in an HTML page that links to another HTML page that contains a Java Applet. Not sure if that's what you are after though...

sorry it is kinda unclear that what i was asking. after some googling, i found i might be able to do something like <applet code= xxx.class ... >

does it mean my java program must extend applet in order to put on the web?

For that to work, your program must extend Applet. Also note that in Applets there is no main method, the Applet's init, start and stop methods are called instead.

There are also java servlet pages that allow you to display HTML pages in your browser from within a Java program, but from your description it sounds like you want the opposite.

I am unaware of any other way to run a Java program from an HTML page, anyone else have any ideas?

well in ur java program u will have to write the following

/* <applet code = "filename"  height = 300 width = 300 >
   </applet code> */

it should be written after the packages you import (i usually write at that position ). you can change height and width accordingly.
and you have to write like writing comments cuz java compiler doesnt understand that particular tagged code

and then save the file in .html form . i guess it should work
or else in the command mode you can use appletviewer

Yes I have already mentioned that k2k can run their program as an applet. Do you know of any way that a java application (ie not an applet) can be run from an HTML link?

well in ur java program u will have to write the following

Help with Code Tags
(Toggle Plain Text)

/* <applet code = "filename" height = 300 width = 300 >
</applet code> */
***********************************************

does it mean my main html file should have a link, linking to another "html file in java format" and must extend to applet?

if it doesn't take too long, would you mind to give a simple example of the java program? maybe just the necessary heading and stuffs, so it would be easier for me to see the first time doing this.

thanks for all the contribution.

Yes I have already mentioned that k2k can run their program as an applet. Do you know of any way that a java application (ie not an applet) can be run from an HTML link?

well actually i used to convert all of my code in an applet form and work. but if u completely wanna run java application using html then try the underneath link .
http://www.java2html.com/
it converts the java code to html .

does it mean my main html file should have a link, linking to another "html file in java format" and must extend to applet?

if it doesn't take too long, would you mind to give a simple example of the java program? maybe just the necessary heading and stuffs, so it would be easier for me to see the first time doing this.

well i cannot write a complete program , but yeah since you have requested i can write a simple one.

import java.awt.*;
import java.applet.*;
/* <applet code = "me" height = 300 width = 300 >
</applet code> */
public class me extends applet 
{
public void paint (Graphics g)
{
 g.drawString("hi",25,25);
}
}

well honestly i havent compiled the code , but to the best of my knowledge it must work .

that is very nice of all of you.

rahul8590, thanks for your example.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.