Java.NET: Integration of Java and .NET
-
Upload
sukhpal-singh-gill -
Category
Education
-
view
323 -
download
2
Transcript of Java.NET: Integration of Java and .NET
Available Online: 03-10-2015 1
Java.NET: Integration of Java and .NET
Sukhpal Singh Gill Computer Science and Engineering Department, Thapar University, Patiala, Punjab, India-147004
ssgill[at]thapar[dot]edu
Introduction
This article describes how integrate Java with Microsoft Technology. Sometimes there may be
need an application where integrate both technologies. This article describes how to 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.
Background
Two IDE used for this Application
1. Visual Studio 2005
2. Eclipse
This diagram describes the main flow between Java and .NET.
The main concept behind the scene is Applet, created a JAR file which contains one applet and
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, create a JAR file using Java. As already explained, used Eclipse, just take a look the
hierarchy of Java applet and function.
Available Online: 03-10-2015 2
These methods are created and created a "Jar" file, named JavaNet.Jar. Now 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, used an Applet tag for invoking the applet. Now from the
ID, MyJavaApplet, call any Java methods from file.
The following is the JavaScript using to call all Java methods
Available Online: 03-10-2015 3
var ID= "<%=txtnum1.ClientID%>"; //Read Client ID of TextBox
//Call Java Welcome Message
function btnCallJava_onclick()
{
MyJavaApplet.WelcomeToJava();
}
// Get Message From Java
function btnNetMessage_onclick() {
var message=MyJavaApplet.MessageForNetFromJava();
alert(message);
}
//Pass Argument To Java Methods
function btnServerValueSend_onclick()
{
var Message= document.getElementById(ID);
var result=MyJavaApplet.MessageFromNETServerSide(Message.value);
alert(result);
}
OutPut
Call Welcome Message
Send Server Side Value To Java
Available Online: 03-10-2015 4
Get Message From Java
Points of Interest
.NET and Java, both are leading the world's technology, and by integrating both of them to do
anything that you want to do.
Sukhpal Singh Gill obtained the Degree of Master of Engineering in Software Engineering from Thapar
University, Patiala. Mr. Singh received the Gold Medal in Master of Engineering in Software Engineering.
Presently he is pursuing Doctoral degree in Cloud Computing from Thapar University, Patiala. Mr. Singh
is on the Roll-of-honor being DST INSPIRE FELLOW as a SRF Professional. He has done certifications
in Cloud Computing Fundamentals, including Introduction to Cloud Computing and Aneka Platform (US
Patented) by ManjraSoft Pty Ltd, Australia and Certification of Rational Software Architect (RSA) by IBM
India. His research interests include Software Engineering, Cloud Computing, Operating System and
Databases. He has more than 20 research publications in reputed journals and conferences.
Please write your detailed thoughts on how you might think that we can work together @
ssgill[at]thapar[dot]edu