Reputation: 172
I want to run a Simple java program from a Java applet. The following is the code for the program:
import java.io.*;
import java.util.*;
class Termi
{
public static void main(String a[])
{
String[] nu={ "xterm","-e","gedit" };
try
{
Process p=Runtime.getRuntime().exec(nu);
}
catch(Exception e){ }
}
}
This is a program for opening the gedit text editor (I'm on Linux). Now, all I want to do is to execute the above program by clicking a button "Open" in an Applet. Can anybody tell me a way to do that?
Upvotes: 1
Views: 595
Reputation: 718678
Generally speaking you won't be able to launch an external application from an applet. The Java sandbox in which an untrusted applet is executed is not permitted to launch external applications.
If you:
you could potentially work around this restriction. The following references discuss this:
However, this presupposes that you can convince the end users (or their system admin / security staff) to enable a Java plugin at all. A lot of people won't ... for obvious reasons.
IMO, you need to think of a way to edit files that doesn't involve using applets at all.
Upvotes: 4