Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: How to call a java programme from an applet?

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Thanked 0 Times in 0 Posts

    Default How to call a java programme from an applet?

    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 .

    if(actionevent.getActionCommand().equals("Credit Card"))
    System.out.println("Test print2 new");
    FileOutputStream fileoutputstream = new FileOutputStream("c:\\POS\\account1new.txt");
    Runtime runtime = Runtime.getRuntime();
    System.out.println("Test print");
    String s = "java run2";
    debug.log("Before javatestMSR");
    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:

    <td width="50%"><applet NAME="CreditApplet" archive="CCPOS.jar" code="POSReader.class" codebase="." width="115" height="30" MAYSCRIPT></applet></td>

    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.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Thanked 833 Times in 772 Posts
    Blog Entries

    Default Re: How to call a java programme from an applet?

    But i am unable to run the java programme run2 on my PC
    Define 'unable'...are there exceptions? Are you familiar with applet security?
    What Applets Can and Cannot Do (The Java™ Tutorials > Deployment > Java Applets)

  3. #3
    Join Date
    Nov 2011
    Thanked 1 Time in 1 Post

    Default Re: How to call a java programme from an applet?

    By default, reading or writing files are not allowed for a normal applet, so you have to give appropriate permission to the applet by either using .java.policy file or sign the applet with a security certificate.

    Spring 3
    Last edited by cafeteria84; January 22nd, 2012 at 04:06 PM.

Similar Threads

  1. How to call webservice in java?
    By Subhasri in forum Web Frameworks
    Replies: 2
    Last Post: September 30th, 2011, 09:15 AM
  2. Java jar programme with a microcontroller
    By bczm8703 in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: September 11th, 2011, 08:01 AM
  3. call win32 api from java
    By bapu in forum Java Native Interface
    Replies: 3
    Last Post: November 7th, 2010, 09:42 AM
  4. access cisco router with java programme
    By vigneswara in forum Java Theory & Questions
    Replies: 1
    Last Post: May 11th, 2010, 01:36 AM
  5. call recording throuph java
    By 7121987 in forum Java ME (Mobile Edition)
    Replies: 1
    Last Post: April 29th, 2010, 04:12 PM

Tags for this Thread