JNI is the native programming interface for java that is part of JDK.
Using JNI you can operate with other applications and libraries written in other language
such as C,C++.
But the basic question arises when should I use the JNI ?
You want some platform specific information and the standard Java class
library may not support the platform-dependent features needed by your
You have some library application written in other language and
you want to use it in your java application.
You want Java should interact with some low level programming language.
Below is given Simple Example
See that methods have 'native' KeyWord
public native void displayHelloWorld();
public native void displayOther();
private native String getLine(String prompt);
The DLL we are going to use is firstJNI.DLL
This DLL can be generated by VC++ or borland.
Which we will discuss later.
Compile the above code using
Then create header File using
prompt>javah javah -jni HelloWorld
This will create firstJNI.h file
In the header File you will see
To generate DLL
create bcc32.cfg file in %BORLAND_INSTALL%/BCC5/bin Folder
In the bcc32.cfg file add following code
i.e the path for borland compiler and java.
now goto prompt and say
prompt>bcc32 -tWM -tWD firstJNI.c
This will create firstJNI.lib File
prompt>implib -c firstJNI.lib firstJNI.dll
It will generate DLL file.
Now you can run the firstJNI.class file by using java.
Now let see how to generate DLL using VC++
Click File->New->Win32Dynamic-Link Library
Give name and Select A simple DLL project
You will have
Below is given the firstJNI.cpp file
The syntax declaration is same as discussed above. In VC++ it
may throw error for unable to include for jni.h or
firstJNI.h where you have to give path for these header files while including.
The above code will also check for RAM size and print it.
Borland compiler do not provide bios.h so it is not included in the code.
Build all Application and you will get the DLL file.
Go to prompt and run firstJNI.class using java.
So here we can print RAM size!!!
Now since this is the basic we can go further with this.
If you don't set the library path correctly it will throw exception java.lang.UnsatisfiedLinkError: no hello in shared library path
Java MP3 Player by David Barron
A fully functioning MP3 Player with complete source code available for download
A simple way to JTable by Kanad Deshpande
Many face trouble while dealing with JTable. Here is simplest way to handle JTable.
ID Verification using JSP by Nouman Rashid
One of the most important parts of
web development is to make sure that
only authorized users get access to certain areas of the site. This tutorial
takes a look at various steps involved
in making JSP pages which validate a
user ID and password from a MS Access database which contains the username and
Java Native Interface (JNI) by Kanad Deshpande
Java Native Interface (JNI) is one of the intersting interface by java
By using Java Native Interface (JNI) you can operate with other applications and libraries.
Understanding Hibernate ORM for Java/J2EE by Saritha.S.V
Hibernate is the most popular and most complete open source object/relational mapping solution for Java environments.Hibernate's goal is to relieve the developer from 95 percent of common data persistence related programming tasks.
Login codes with JSP,JavaBean from mySQL database by Prakash
my problem is can i have the code to login with the username and password using JSP and JavaBean/Servlets from mySQL database.When the user enters the username and password in the login page then it will go to the requested site.How to do it?
Java Speech Synthesizer by David Barron
Small and simple. Type a sentence and press enter and your computer will speek to you.
Turn EJB components into Web services by Krunal J Patel
Web services have become the de facto standard for communication among applications. J2EE 1.4 allows stateless Enterprise JavaBeans (EJB) components to be exposed as Web services via a JAX-RPC (Java API for XML Remote Procedure Call) endpoint, allowing EJB applications to be exposed as Web services. This article presents a brief introduction to JAX-RPC, outlines the steps for exposing a stateless session bean as a Web service, and provides the best practices for exposing EJB components as Web services
CORBA Technology by Krunal Patel
CORBA defines an architecture for distributed objects. The basic CORBA paradigm is that of a request for services of a distributed object. Everything else defined by the OMG is in terms of this basic paradigm.