Click here to Skip to main content
15,313,293 members
Articles / Programming Languages / Javascript
Posted 16 May 2008


45 bookmarked

Java.NET : Integration of Java and .NET

Rate me:
Please Sign up or sign in to vote.
4.33/5 (42 votes)
26 May 2008CPOL2 min read
A Approch To Integrate Java with .NET Web Application
Java_Net_Logo.gif Download IntegratedNETJavaWeb.zip - 4.21 KB


This article describes how we can integrate Java with Microsoft Technology. Sometimes we may need an application where we integrate both technologies. I am writing this article keeping all beginners in mind, so they can learn something from it. This article describes how we can call some Java methods from .NET code, and pass some values to Java or .NET and vice versa. This is a simple ASP.NET application, which interacts with Java Applets while performing another  operation. The application is very simple to do, but the main thing behind the scene is the idea and implementation logic.


I have used two IDE for this Application

  1. Visual Studio 2005
  2. Eclipse

This digaram describes the main flow between Java nad .NET.


The main concept behind the scene is Applet, I have created a JAR file which contains one applet and I have called Java methods using applet from .NET. Once you get the data using JavaScript, it is up to you to decide how you going to use it on the server side.

Using the Code

First of all, we have to create a JAR file using Java. As I already explained, I have used Eclipse, just take a look the hierarchy of my Java applet and function.


I have created these methods and created a "Jar" file, named JavaNet.Jar. Now I am going to interact with this using .NET. The following is the Java Applet code.

//Welcome Methods will call from .NET
public void WelcomeToJava()
  JOptionPane.showMessageDialog(null,"Hi .NET Welcome To Java");
//Return Value To .NET
public String  MessageForNetFromJava()
 return "Hi .NET, Nice To Meet you !!";	
//Take Argument from .NET and Reply
public String MessageFromNETServerSide(String Message)
 return "From Java : " + Message ;

Now, in the ASP.NET page, I have used an Applet tag for invoking the applet. Now from the ID, MyJavaApplet, I can call any Java methods from file.


The following is the JavaScript I'm using to call all Java methods

var ID= "<%=txtnum1.ClientID%>"; //Read Client ID of TextBox
//Call Java Welcome Message
function btnCallJava_onclick() 
// Get Message From Java
function btnNetMessage_onclick() {
var message=MyJavaApplet.MessageForNetFromJava();
//Pass Argument To Java Methods
function btnServerValueSend_onclick()
   var Message= document.getElementById(ID);
   var result=MyJavaApplet.MessageFromNETServerSide(Message.value);


Call Welcome Message


Send Server Side Value To Java


Get Message From Java


Points of Interest

.NET and Java, both are leading the world's technology, and by integreting both of them we can do anything we want to do .


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


About the Author

Abhijit Jana
Technical Lead
India India
.NET Consultant | Former Microsoft MVP - ASP.NET | CodeProject MVP, Mentor, Insiders| Technology Evangelist | Author | Speaker | Geek | Blogger | Husband

Blog : http://abhijitjana.net
Web Site : http://dailydotnettips.com
Twitter : @AbhijitJana
My Kinect Book : Kinect for Windows SDK Programming Guide

Comments and Discussions

Questionjava vs .net Pin
leejcarol13-Mar-20 0:39
Memberleejcarol13-Mar-20 0:39 
QuestionNot able to call the jar file Pin
sanket tiger7-Feb-18 23:57
Membersanket tiger7-Feb-18 23:57 
QuestionHow to call Java Applet functions from ASP.NET Web Service Pin
Member 627246216-Feb-16 20:59
MemberMember 627246216-Feb-16 20:59 
QuestionProject Java Applet Code Pin
valiengo27-May-15 10:23
Membervaliengo27-May-15 10:23 
QuestionBrowser hangs when I clicked on Call Java and In my defaul.aspx file under Applet tag code="myjava.net.MyApplet" shows was not found. Pin
sachin shelake27-Nov-12 21:35
Membersachin shelake27-Nov-12 21:35 
GeneralMy vote of 5 Pin
Massimo Conti14-Jul-12 4:56
MemberMassimo Conti14-Jul-12 4:56 
GeneralMy vote of 2 Pin
Marcelo Lujan [El Bebe.Net ]22-Feb-12 16:56
MemberMarcelo Lujan [El Bebe.Net ]22-Feb-12 16:56 
QuestionThanks Pin
sanya.fesak21-Sep-11 19:06
Membersanya.fesak21-Sep-11 19:06 
Generaljava document Pin
Tarık Murat18-May-10 1:53
MemberTarık Murat18-May-10 1:53 
GeneralMy vote of 1 Pin
MeneDev10-May-10 7:50
MemberMeneDev10-May-10 7:50 
GeneralGreat Pin
Brij23-Dec-08 2:58
mentorBrij23-Dec-08 2:58 
GeneralRe: Great Pin
Abhijit Jana18-Oct-09 11:25
professionalAbhijit Jana18-Oct-09 11:25 
GeneralInteresting... Pin
stevjhon17-Oct-08 5:37
Memberstevjhon17-Oct-08 5:37 
GeneralRe: Interesting... Pin
Abhijit Jana18-Oct-09 11:25
professionalAbhijit Jana18-Oct-09 11:25 
QuestionWhere is the .NET part? Pin
Victor van Hagen26-May-08 9:47
MemberVictor van Hagen26-May-08 9:47 
AnswerRe: Where is the .NET part? Pin
Abhijit Jana26-May-08 16:35
professionalAbhijit Jana26-May-08 16:35 
GeneralRe: Where is the .NET part? Pin
N a v a n e e t h26-May-08 17:51
MemberN a v a n e e t h26-May-08 17:51 
GeneralRe: Where is the .NET part? Pin
Victor van Hagen27-May-08 2:16
MemberVictor van Hagen27-May-08 2:16 
Questioncan you do this without javascript? Pin
mattvil26-May-08 4:15
Membermattvil26-May-08 4:15 
GeneralInteresting, but the Web Services are better solution Pin
Stoyan K Petrov26-May-08 3:11
MemberStoyan K Petrov26-May-08 3:11 
GeneralSuperb !!! Pin
Ashutosh Phoujdar21-May-08 3:31
MemberAshutosh Phoujdar21-May-08 3:31 
GeneralRe: Superb !!! Pin
Abhijit Jana21-May-08 6:07
professionalAbhijit Jana21-May-08 6:07 
GeneralGreat Effort!!! Pin
Samir NIGAM19-May-08 18:11
MemberSamir NIGAM19-May-08 18:11 
GeneralRe: Great Effort!!! Pin
Abhijit Jana19-May-08 18:39
professionalAbhijit Jana19-May-08 18:39 

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.