# How to call Java Applet from a VB or .Net Application?



## VanithaS (Jun 13, 2008)

I need to call the Java Applet in .net Applications. ie I need to communicate back forth between the two.


----------



## Chicon (Jul 29, 2004)

Hi VanithaS,

Welcome to TSG ! 

Java applets are designed to be executed from a web browser. Their URL is referred by the *http://www.w3schools.com/TAGS/tag_applet.asp* tag in HTML pages. 
As applets are only executed on the client side of a net application, the Java runtime (JRE) must be installed on each client computer.


----------



## VanithaS (Jun 13, 2008)

Hi Chicon,
Thanks for the reply. 

JRE is already installed. I want to do the automation for that particular Java Applet ( which is in Webpage). ie I want to send the command to that Applet and get the response . But I don't know how to communicate with that. 

Suggest me.

Thanks,
Vanitha


----------



## Chicon (Jul 29, 2004)

There's no direct way to communicate with an applet.

Assuming that your application builds dynamically the web page that refers to the applet, you may pass some parameters to the applet inside the tag.
Example :
- In the web page :

```
[SIZE=2]
<APPLET CODE=MyApplet WIDTH=300 HEIGHT=200>
        <PARAM NAME=[COLOR=BLUE]parameter1[/COLOR] VALUE="value1">
        <PARAM NAME=[COLOR=BLUE]parameter2[/COLOR] VALUE="value2">
        <PARAM NAME=[COLOR=BLUE]parameter3[/COLOR] VALUE="value3">
</APPLET>
[/SIZE]
```
- In the applet code, the parameters are recovered the following way :

```
[SIZE=2]
public class MyApplet extends JApplet {
   private String param1;
   private String param2;
   private String param3;
   
   public void init() {
      param1 = this.getParameter("[COLOR=BLUE]parameter1[/COLOR]");
      param2 = this.getParameter("[COLOR=BLUE]parameter2[/COLOR]");
      param3 = this.getParameter("[COLOR=BLUE]parameter3[/COLOR]");
   }
   ...
   ...
}[/SIZE]
```
From an applet, you may also upload some data to the web server.
There's a open source package called *JUpload* you may download from here.
The jar file contains API documentations, the sources and the libraries.


----------



## pvc_ (Feb 18, 2008)

you may wanna sniff the packets that are sent to the applet and see if you can generate the same packets; that way you can connect to the server with a socket and just send the packets rather than loading applets...


----------

