Click here to Skip to main content
13,504,022 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


8 bookmarked
Posted 2 Jan 2013

Running a Java applet from an ASP.NET website

, 2 Jan 2013
Rate this:
Please Sign up or sign in to vote.
Integration of a Java applet in ASP.NET.


This article helps you to understand how to use Java applet in your ASP.NET website.


Many times you need to access local files on client machine from your website. In dot net you can use ActiveX control.

But ActiveX you can run only in IE, and for other browser you need to make some settings which is not safe.

Using the code

Make one jApplet in net beans as given below :

add following function code on button click :

public String readFile(String fn) { 
   String thisLine, ret = ""; 
 try { 
   FileInputStream fin =  new FileInputStream(fn); 
   BufferedReader myInput = new BufferedReader 
                     (new InputStreamReader(fin));
   while ((thisLine = myInput.readLine()) != null) {  
     ret += thisLine + "\n";
 } catch (Exception e) {
   ret = "Cannot load, exception!";
 return ret;

Then build this applet.

Then right click project-> properties-> Web start-> Under signing->Customize->select Self-sign by generated key-> clock OK

This will sign your jar file of your java applet project.

Then make one website add one folder name it as applet and copy jar files and class files of applet as shown below:

Then add below code in .aspx page

<applet code="javaapplication4/TestApplet.class" 

       archive="applet/TestApplet1.jar" width="325" height="325">  

you can also call applet using deploy java script:

<script src="" type="text/javascript"></script>
<pre><script type="text/javascript">
    var attributes = { code: 'javaapplication4.TestApplet.class',
        archive: 'applet/TestApplet1.jar', 
        width: 325, height: 325 
    var parameters = { fontSize: 16 };
    var version = '1.6';
    deployJava.runApplet(attributes, parameters, version); 

then run the website

It will give you following pop up for enabling Java applet

Check the check-boxes and click Run

Then type any local file name in text box and click on Load

It will allow you to read any file on client machine and it will show you content of that file.

You can test this by deploying website on IIS and run it from different machine.

If you want to send some parameter to applet from asp page you can use this link:

For more information you can use this link:

Points of Interest

It will reduce your time and efforts of setting security of browser for ActiveX. It works with all browser which supports Java.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
India India
Experience in dot net specifically worked on bio metric devices.

You may also be interested in...

Comments and Discussions

QuestionMY japplet shows blank on the browser. Pin
omotoyosi16-Feb-16 21:33
memberomotoyosi16-Feb-16 21:33 
QuestionSource Code Pin
750664373711-Feb-16 20:53
professional750664373711-Feb-16 20:53 
QuestionCalling .JAR in .NET through aspx page Pin
Manish_0071-Aug-14 0:00
memberManish_0071-Aug-14 0:00 
QuestionHelp me! Pin
wingchunpolice6-May-13 16:28
memberwingchunpolice6-May-13 16:28 
AnswerRe: Help me! Pin
revathivanga4-Sep-13 21:42
memberrevathivanga4-Sep-13 21:42 
GeneralMy vote of 5 Pin
MAU7872-Jan-13 18:23
memberMAU7872-Jan-13 18:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.180417.1 | Last Updated 2 Jan 2013
Article Copyright 2013 by MAU787
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid