saurin badiyani

Greenhorn
+ Follow
since Apr 01, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by saurin badiyani

I am trying to make JNI object that is interfacing parallel port using DOS.h inportb
& outportb functions.
I have the following java files.
------------------------------
Dimmer.java
------------------------------
class Dimmer
{
int intensity;

public Dimmer(int intensity)
{
this.intensity=intensity;
System.loadLibrary("NativeDimmer");
}
public native void applyIntensity();
}
------------------------------
DimmerDemo.java
------------------------------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
public class DimmerDemo extends JFrame implements ActionListener,ChangeListener
{
JSlider slider;
JButton exit;
Dimmer d;
RunnerThread runner;

public static void main(String[] args)
{
JFrame frame = new DimmerDemo();
frame.show();
}
public DimmerDemo()
{
setSize(200,100);
setTitle("Project DAS: Device interface Demo");
addWindowListener(new WindowAdapter()
{
public void WindowClosing(WindowEvent e)
{
System.exit(0);
}
});
Container contentPane= getContentPane();
contentPane.setLayout(new GridLayout(3,1));
contentPane.add(new JLabel(" Light-Intensity "));
slider = new JSlider(0,10,5);
slider.addChangeListener(this);
slider.setPaintTicks(true);
slider.setMajorTickSpacing(2);
slider.setMinorTickSpacing(1);
slider.putClientProperty("JSlider.isFilled",Boolean.TRUE);
contentPane.add(slider);

exit=new JButton(" Exit ");
exit.addActionListener(this);
contentPane.add(exit);
d=new Dimmer(5);
runner=new RunnerThread("runner",d);
runner.start();
}
public void stateChanged(ChangeEvent ce)
{
JSlider temp=(JSlider)ce.getSource();
d.intensity=slider.getValue();
}
public void actionPerformed(ActionEvent ae)
{
Object source=ae.getSource();
if(source==exit)
{
d.intensity=-1;
runner.stop();
try
{
runner.join();
}catch(InterruptedException e){}
System.exit(0);
}
}

}
class RunnerThread extends Thread
{
Dimmer dimmer;
public RunnerThread(String name,Dimmer dimmer)
{
super(name);
this.dimmer=dimmer;
}

public void run()
{
try
{
dimmer.applyIntensity();
}
catch(Exception e) { }
}
}
-----------------------------
NativeDimmer.cpp
------------------------------
#include <stdio.h>
#include <jni.h>
#include "Dimmer.h"
#include <dos.h>
#define OUTPORT 0x378
#define INPORT 0x379
JNIEXPORT void JNICALL Java_Dimmer_applyIntensity
(JNIEnv *env, jobject obj)
{
jclass cls;
jfieldID fid;
jint i;
unsigned char toggle=0x7f;
cls=(*env)->GetObjectClass(env,obj);
fid=(*env)->GetFieldID(env,cls,"intensity","I");
i=(*env)->GetIntField(env,obj,fid);

while(i!=-1){
i=(*env)->GetIntField(env,obj,fid);
printf("\ri=%2d",i);
while(inportb(INPORT)!=toggle);
toggle^=0x80;
while(inportb(INPORT)!=toggle);
outportb(OUTPORT,0x00);
delay(10-i);
outportb(OUTPORT,0x01);
}
}
problem:
when i try to compile and make a dll through
CL command (dll maker From Microsoft)
CL -Ic:\jdk1.3\include -Ic:\jdk1.3\include\win32 -LD NativeDimmer.cpp -FeNativeDimmer.dll

it shows errors saying
_inportb() not found DOS.h
_outportb() not found in DOS.h
_delay() not found in dos.h
when i tried the dos.h provided by TurboC
the CL replied with errors showing problems
with this DOS.H which contains the functions
i require namely inportb(),outportb() & delay()
when the same was tried with bcc32 dll maker
from borland it showed errors in jni.h
bcc32 -Ic:\jdk1.3\include -Ic:\jdk1.3\include\win32 -WD NativeDimmer.cpp -oNativeDimmer.dll
21 years ago
i have a scientific code written in c language and i want to call that code in my java program through java native interface(jni), the problem i am facing is i am unable to find CL compiler for c sourcecode, so i am not able to form the required dll.
can any one suggest me the appropriate cl compiler and where can i get it (if possible url for download)
21 years ago
I am developing a web based application where i have Linux based apache server, and on it I am using PHP for my server side pages, and i want to interface it with java for my furthur processing,
is it possible ?
and if possible how?
21 years ago
I am developing a web based application where i have Linux based apache server, and on it I am using PHP for my server side pages, and i want to interface it with java for my furthur processing,
is it possible ?
and if possible how?
21 years ago