How to call a java program from an applet?
Posted by prativa
on December 17, 2011 at 2:41 AM PST
I want to call a java program from an applet which is on a webpage.The java program we are using is placed on the client machine.
When we click on the applet i have the following code in the applet action .
System.out.println("Test print2 new");
FileOutputStream fileoutputstream = new FileOutputStream("c:\\POS\\account1new.txt");
Runtime runtime = Runtime.getRuntime();
String s = "java run2";
Process process = runtime.exec(s);
debug.log("After Execute javatestMSR new");
System.out.println("s value "+s);
PrintLog streamgobbler = new PrintLog(process.getErrorStream(), "ERROR");
PrintLog streamgobbler1 = new PrintLog(process.getInputStream(), "OUTPUT", fileoutputstream);
int i = process.waitFor();
System.out.println("i value "+i);
//File file = new File("c:\\POS\\account1.txt");
But i am unable to run the java programme run2 on my PC. Please note i have successfully done the following.
1> Added the run2 class in the classpath.
2> Am able to run the claas run2 in command line from any location
3> If i run the above applet as a stand alone programme in the client machine, i am able to run the programme.
Problem : I am unable to run the java programme run2 when i put it in a JSP page and try running from the web browser like shown below:
Please advice. How can I change the setting in JVM for Java environment in client or server side to run this programme from web browser.