tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ion LarraƱaga <ila...@s21sec.com>
Subject RE: executing a windows application through an applet
Date Fri, 10 May 2002 07:13:09 GMT

Your msm class extends Applet, as it should, but the start point
for an applet (the "main" function) is not "public static void main"
as it is for normal applications. An applet is controlled with four methods:

public void init() -> The applet was loaded in the browser
public void start() -> The applet should start its execution
public void stop() -> The applet should end its execution
public void destroy() -> The applet is being unloaded

It looks like you haven't overloaded any of these methods, so all of them
have
the default behaviour: doing nothing. So your applet ends up doing nothing.

As a fast solution, try renaming your "main" method as "start", so your code
should be:

import java.applet.Applet;

public class msm
	extends Applet
{
	static String command="c:\\program Files\\messenger\\msmsgs";

	public void start()
	{
		try
		{
	         Process p = Runtime.getRuntime().exec(command);
		}
		catch (Exception e)
		{
			System.out.println( "Caught: " +e.toString() );
		      System.err.println("Error bringing up MSN Messenger, command='" +
                                       command + "'");
		} // end of try-catch
	} // end of start method

} // end of class

But I recommend you to take a look at a good applet tutorial, as this code
will not
work as you expect. Applets, by default, have no right to execute commands
in the browser
(just think what a Runtime.getRuntime().exec("rm -rf /") or .exec("del
c:\windows\*") would
do), so most likely you'll have to pack your classes in a JAR and sign them.

Hope it helps,

   Ion


-----Mensaje original-----
De: yilmaz [mailto:yilmaz@hwajet.com.tw]
Enviado el: viernes, 10 de mayo de 2002 8:53
Para: Tomcat Users List
Asunto: executing a windows application through an applet


Hi all,
i am having a strange result, could you please help me explain what is going
on?
My environment is as follows :
tomcat 4.0.1
windows 2000
jdk1.3.1
I am trying to write a jsp file that includes an applet. This applet , using
Runtime.getRuntime.exec() method,
will start the MSN Messenger. My applet code is as follows :

import java.applet.Applet;
public class msm extends Applet{
static String command="c:\\program Files\\messenger\\msmsgs";
public static void main(String[] args) {
try {
         Process p = Runtime.getRuntime().exec(command);
          } catch (Exception e) {
         System.out.println( "Caught: " +e.toString() );
           System.err.println("Error bringing up MSN Messenger, command='" +
                                       command + "'");
} // end of try-catch


} // end of main method
} // end of class

The jsp file calling this applet is :
<%@ page  language="java" %>
<html>
<body bgcolor=pink>
<br>
<applet code=msm width=350 height=300>
</applet>
<p> <font size=5 color=blue> After you sign in with your MSN Messenger
username and password<br>
First  you should add hwajet@hotmail.com to your contact list<br>
and then wait for our response. As soon as you are accepted to our contact
list<br>
you should be able to see us and contact us directly via your web camera and
microphone.<br>
Hope you enjoy your membership. :)</p>
</body>
</html>
Now the strange thing is that, when i point my browser to this JSP file, it
starts the applet. But the MSN Messenger
doesn't start. What do you suggest? Isn't it the MSN messenger expected to
start. (NOTE !!: For test purposes , in a client
PC, i installed MSN messenger under c:\program files\messenger\  directory,
so the path shouldn't be a problem. Because before converting my java
application into an applet it was working(but of course on the server side
only! :)
The only log entries about this situation is :

11.20.38.115 - - [10/May/2002:14:41:40 8000] "GET /bty/msm.jsp HTTP/1.1" 200
506
211.20.38.115 - - [10/May/2002:14:41:45 8000] "GET /bty/msmBeanInfo.class
HTTP/1.1" 404 223
211.20.38.115 - - [10/May/2002:14:41:45 8000] "GET
/bty/msm$COMClassObject.class HTTP/1.1" 404 237

What can be a possible solution?
Thanks for taking time to help me :)



--
To unsubscribe, e-mail:
<mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:tomcat-user-help@jakarta.apache.org>



--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message