About dll from java swing
Hi,
I hava class (send sms from java) in dll - ActiveXComponent type, his name: SMSCom
dll name: SMSSender
that get in his constractor: (in VB I wrote this)
SMSObj.password = password;
SMSObj.Username = user;
SMSObj.Source = phone;with this code I'm connect to the dll file and his object, but
I don't know how to give this object this parameters.
ActiveXComponent ax = new ActiveXComponent("SMSCom.SMSSender");
Dispatch SMSObj = (Dispatch) ax.getObject();Thanks alot for any help :)
Thank you so moch, you helped me alot!!!!!
I you coul'd help me with last little thing I'll be happy:
but I have error, it is not attached to your help, the error link to this line
(I have jacob.dll +jacob.jar)
ActiveXComponent ax = new ActiveXComponent("SMSCom.SMSSender");the error messege:
Exception occurred during event dispatching:
com.jacob.com.ComFailException: Can't get object clsid from progid
at com.jacob.com.Dispatch.createInstance(Native Method)
at com.jacob.com.Dispatch.<init>(Dispatch.java)
at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java)
at com.matarotqm.QM6.model.Test1.<init>(SmsDll.java:51)
at com.matarotqm.QM6.model.SmsDll.<init>(SmsDll.java:27)
at com.matarotqm.QM6.view.Sms.actionPerformed(Sms.java:273)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.Dialog$1.run(Unknown Source)
at java.awt.Dialog$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Dialog.show(Unknown Source)
at java.awt.Component.show(Unknown Source)
at java.awt.Component.setVisible(Unknown Source)
I have in this object (SMSObj) method that I have to set her text as String and phone as String.
do I call method from SMSObj like this?
System.out.println("Calling method..");
Dispatch.call(SMSObj,"SendSMS","Hello From Java","0507657661");
Similar Messages
-
Viewing and printing a PDF file from Java Swing Application
Hello,
I need to view and print PDF files from Java Swing Application.How do I do that?I appreciate your help.
Thank you
Sumana SomareddyIf you have a link to the URL pointing to the PDF file, you can allow the browser to open it. Then use the print function of the browser to print the PDF document.
Regards,
Tak. -
Calling back c++ method in an exe (not a dll) from java?
Hi all,
I have to make an hybrid C++/java from an existing C++
application that compiled is a big single exe not a dll.
I'm running under win32.
The application consists of several windows. The hybrid
will have widows in C++ and some in java. They have the
same menu and tool bar. In the C++, there are some
callbacks called when a button is pressed. How to call
these callback from java given the fact that the JVM and
the java classes are launched by the exe file.
I know how, from C++, start JVM and call my java window.
I also know how to call a C++ method that is in a dll from
java. It's from the tutorial
http://java.sun.com/docs/books/tutorial/native1.1/index.html
But I don't know how to call a C++ method that is in in an
exe which has launch a JVM from an object running in this
JVM.
Is there somewhere an example like this?
Thanks,
Xavier.Thanks this helped.
For those who want a complete example, here it is:
Tested on XP, java 1.4.2, VC++ 6.0.
************ File invoke.cpp *****************************
#include <stdlib.h>
#include <jni.h>
#ifdef _WIN32
#define PATH_SEPARATOR ';'
#else /* UNIX */
#define PATH_SEPARATOR ':'
#endif
#define USER_CLASSPATH "." /* where Prog.class is */
void JNICALL displayHelloWorld(JNIEnv *env, jobject obj)
printf("Hello world: made by printf from C++\n");
return;
void main() {
JNIEnv *env;
JavaVM *jvm;
JavaVMInitArgs vm_args;
jint res;
jclass cls;
jmethodID mid;
jstring jstr;
jobjectArray args;
char classpath[1024];
int result;
/* IMPORTANT: specify vm_args version # if you use JDK1.1.2 and beyond */
JavaVMOption options[3];
options[0].optionString = "-verbose:gc";
sprintf (classpath, "-Djava.class.path=%s", USER_CLASSPATH);
options[1].optionString = classpath;
options[2].optionString = "-Djava.compiler=NONE";
vm_args.options = options;
vm_args.nOptions = 3;
vm_args.ignoreUnrecognized = JNI_TRUE;
vm_args.version = JNI_VERSION_1_4;
/* IMPORTANT: Note that in the Java 2 SDK, there is no longer any need to call
* JNI_GetDefaultJavaVMInitArgs. It causes a bug
/* Append USER_CLASSPATH to the end of default system class path */
/* Create the Java VM */
res = JNI_CreateJavaVM(&jvm,(void**)&env, &vm_args);
if (res < 0) {
fprintf(stderr, "Can't create Java VM\n");
exit(1);
cls = env->FindClass("mypackage/Prog");
if (cls == 0) {
fprintf(stderr, "Can't find mypackage/Prog class\n");
exit(1);
JNINativeMethod nm;
nm.name = "displayHelloWorld";
/* method descriptor assigned to signature field */
nm.signature = "()V";
nm.fnPtr = displayHelloWorld;
env->RegisterNatives(cls, &nm, 1);
mid = env->GetStaticMethodID(cls, "main", "([Ljava/lang/String;)V");
if (mid == 0) {
fprintf(stderr, "Can't find Prog.main\n");
exit(1);
jstr = env->NewStringUTF(" from C++! calleded by C++, using argument from C++ but java method");
if (jstr == 0) {
fprintf(stderr, "Out of memory\n");
exit(1);
args = env->NewObjectArray(1,
env->FindClass("java/lang/String"), jstr);
if (args == 0) {
fprintf(stderr, "Out of memory\n");
exit(1);
env->CallStaticVoidMethod(cls, mid, args);
jvm->DestroyJavaVM();
}********************* File ./mypackage/Prog.java **************************
package mypackage;
public class Prog {
public native void displayHelloWorld();
public static void main(String[] args) {
System.out.println("Hello World" + args[0] +"\n");
Prog prog = new Prog();
prog.displayHelloWorld();
System.out.println("(called from java)");
System.out.println("\nSo to sumurize:");
System.out.println(" -1 Starting point is an exe (not DLL, there is no DLL) so C++ code");
System.out.println(" -2 From C++ call java method using argument from C++");
System.out.println(" -3 From java, that was launched by the exe, call to");
System.out.println(" a native using the RegisterNatives in C++\n");
System.out.println("You got a bidirectional example with as starting point");
System.out.println("a single exe, launching JVM, loading class call back C++!");
}******************* Command line for all ****************************************
javac mypackage/Prog
cl -I"D:\Program Files\j2sdk1.4.2_03\include" -I"D:\Program Files\j2sdk1.4.2_03\include\win32" -MT
invoke.cpp -link D:\PROGRA~1\j2sdk1.4.2_03\lib\jvm.lib
(Remark, the last path is using the short name for "Program Files" because with the blank
even adding double quotes result into an error)
You must have jvm.dll in your path for me it's Path=D:\Program Files\j2sdk1.4.2_03\jre\bin\client;
Then simply call invoke and see the result. :-) -
Fall into a trouble when calling a dll from java in linux
Hi, experts:
I encountered a big trouble when using JNI to call a C++-compiled DLL from java in Linux: The DLL function didn't execute immediately after the invocation, and was deferred till the end of the Java execution. But all worked well after migrating to windows. This problem made me nearly crazy. Can somebody help me? Thanks in advance.
Linux: fedora core 8, jdk1.6.0_10,
compile options: g++ -fPIC -Wall -c
g++ -sharedIt looks like the OP compiled the C source file and linked it into a Windows .dll, which would explain why it worked flawlessly in Windows. (Though I must say the usage of GCC would make someone think it was compiled in Linux for Linux, GCC also exists for Windows, so I'm not sure it's a Windows .dll either...)
@OP: Hello and welcome to the Sun Java forums! This situation requires you to make both a .dll and a .so, for Windows and Linux. You can then refer to the correct library for the operating system using System.loadLibrary("myLibrary"); without any extension.
s
Edited by: Looce on Nov 21, 2008 11:33 AM -
Hi,
I want to know how one can call a VB dll from Java.I know it is something like calling a C dll which in turn calls the VB dll.I also went through the tutorial provided on the sun site and was able to call a C dll through java but I still do not know how to call a VB dll from java.
regards,
AnshumanHave you checked google?
First hit. Reply 17. -
To read a DLL from java using JNI
Hi,
I had some DLL files (VB 5.0) which are providing interfaces. Is there any chance of accessing that using java (JNI). Also is there any De - Compiler available so that I can get the source code of the DLL file.
Regards,
Hari.Hola Hari
To make a dll loadable through JNI, the interface
inside
the dll must be implemented the JNI way. Also a COM
interface does not help.
I would reccomend a certain product to automatise the
JNI interfacing process, but that would
require that you have the sourcecode of the dll
available.
But one thing you can do is to write a wrapper that
contains the dll classes and is implemented the JNI
way.
More precisely you write an interface wrapper in c/c++
that matches the methods of the dll and does use JNI
methods. Now inside that c++ wrapper you load the dll
and forward the calls from java to c++ vice versa.
Download the demo version of CENTRO.java here:
www.ablon.de
Bye, nilsHi Nils,
Thank you for your suggestion. Im new to JNI.
That dll's are in Visual Basic. I don't have the source code of the dll file. I got the interfaces available in the dll file from a Visual Basic program which make use of the dll file(which we are talking about). As I know only the method signatures in the interfaces(dll file), I request you to kindly provide me some help to wrap it in C/C++ program.
Thanks in advance.
Regards,
Hari. -
Opening browser window from Java Swing
Hi
I am trying to open
1) a word document on the click of a button from a Java-Swing based application running only on windows based system.
Currently the code uses 'rundll' and calls 'a.doc'
it requires that the application be installed and run only from a specific location in the windows' system.
i would like to modify the code in one of the following ways
1) open the word doc irrespective of its location and that of the executable jar which is trying to open this file
2) upload the word document to a website and direct the application to open that webpage on button click, etc
i believe that the latter may be simple but i do not have any idea about how to go about it
i would appreciate some guidance about it.Hi,
I was trying to run the code, for embeding the mozilla web browser in my java application which is running at linux fedoracore2. I set all the environment variables, like MOZILLA_FIVE_HOME and LD_LIBRARY_PATH. I can able to compile successfully but if i run the code, i got the error message like this
Exception in thread "main" java.lang.Error: Untranslated exception
at sun.nio.ch.Net.translateToSocketException(Net.java:63)
at sun.nio.ch.Net.translateException(Net.java:79)
at sun.nio.ch.Net.translateException(Net.java:85)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:61)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:52)
at org.jdesktop.jdic.browser.MsgClient.<init>(Unknown Source)
at org.jdesktop.jdic.browser.NativeEventThread.<init>(Unknown Source)
at org.jdesktop.jdic.browser.WebBrowser.<clinit>(Unknown Source)
at IEInJava.main(IEInJava.java:8)
Caused by: java.net.SocketException: Unresolved address
at sun.nio.ch.Net.translateToSocketException(Net.java:55)
... 8 more
Caused by: java.nio.channels.UnresolvedAddressException
at sun.nio.ch.Net.checkAddress(Net.java:30)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:115)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
... 5 more
Thats the error.
I could not find out, where i had made the mistake, i need help. Any suggestion and comments are most welcome. Thanks. -
UnsatisfiedLinkError - Trying to access a DLL from Java
I am trying to use the Java Native Interface (JNI) to run some C++ code from Java. I tried a simple test program to teach myself that, and it worked perfectly. However, now that I'm tackling a bigger project (A data acquisition program), I get an UnsatisfiedLinkError in the line that calls the function from the DLL.
Here is the stacktrace: Exception in thread "AWT-EventQueue-0" java.lang.Error: java.lang.reflect.Invoca
tionTargetException
at org.jdesktop.application.ApplicationAction.actionFailed(ApplicationAc
tion.java:859)
at org.jdesktop.application.ApplicationAction.noProxyActionPerformed(App
licationAction.java:665)
at org.jdesktop.application.ApplicationAction.actionPerformed(Applicatio
nAction.java:698)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:19
95)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.jav
a:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6263)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
at java.awt.Component.processEvent(Component.java:6028)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4630)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2475)
at java.awt.Component.dispatchEvent(Component.java:4460)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jdesktop.application.ApplicationAction.noProxyActionPerformed(App
licationAction.java:662)
... 26 more
Caused by: java.lang.UnsatisfiedLinkError: fileiotest.dllinterface.startget()V
at fileiotest.dllinterface.startget(Native Method)
at fileiotest.dllinterface.start_daq(dllinterface.java:26)
at fileiotest.FileIOTestView.startrun(FileIOTestView.java:680)
... 31 moreI have made sure that the DLL is in the classpath, using both the -classpath tag and by setting the PATH variable. Is something wrong with my DLL itself, perhaps?Yes, I have.
I didn't include the code yet because I thought if someone had similar trouble, there might be something obvious I am overlooking and they wouldn't even need to see the code. I can provide it, however.
This is the C++ DLL
// consoledaq.cpp : Defines the entry point for the console application.
#include <windows.h> /* Compiler's include files's */
#include <string.h>
#include <stdio.h>
#include "cbw.h"
#include "stdafx.h"
#include "dllinterface.h"
#include "jni.h" //can copy or give full path
#include <math.h>
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
return TRUE;
#define BOARD_NUM 0 /* Number of A/D board as defined with InstaCal */
#define BUF_SIZE 10048 /* Size of buffer */
#define NUM_SECS 10 /* Number of secs to collect data */
#define ADRANGE BIP5VOLTS /* A/D voltage range */
#define TIMER_NUM 1 /* Windows timer used by this program */
static HGLOBAL MemHandle32;
/* Variables for AinScan */
static unsigned short *ADValues; /* Win32 pointer to A/D buffer */
static HGLOBAL ADMemHandle;
static short ADCurStatus; /* Current status for D/A scan */
static long ADCurCount; /* Current count for A/D scan */
static long ADCurIndex; /* Current index for A/D scan */
int ADOptions;
long Count, Rate;
float Voltage, Voltage2;
unsigned short CurValue, CurValue2;
JNIEXPORT void JNICALL
Java_daq_startget(JNIEnv *env, jobject obj)
cbErrHandling (PRINTALL, STOPALL); /* Set library's error handling */
ADCurStatus = RUNNING;
ADCurIndex = 0l;
ADCurCount = 0l;
/* Allocate A/D Windows buffer */
ADMemHandle = cbWinBufAlloc ((long)BUF_SIZE);
/* Allocate a local WIN32 buffer to hold A/D Data */
MemHandle32 = GlobalAlloc(GMEM_FIXED | GMEM_DDESHARE, BUF_SIZE *sizeof(short));
/* Get a 32-bit pointer to the A/D WIN32 buffer */
ADValues = (unsigned short *)GlobalLock(MemHandle32);
/* Start up background A/D scan */
Count = BUF_SIZE;
Rate = BUF_SIZE / (NUM_SECS * 2);
ADOptions = BACKGROUND | CONTINUOUS;
cbAInScan (BOARD_NUM, 0, 1, Count, &Rate, ADRANGE, ADMemHandle, ADOptions);
JNIEXPORT void JNICALL
Java_daq_stopget(JNIEnv *env, jobject obj)
cbStopBackground(BOARD_NUM, AIFUNCTION); /* Stop A/D subsystem background scan */
if (ADMemHandle)
cbWinBufFree (ADMemHandle); /* Free allocated memory */
if (MemHandle32)
GlobalFree (MemHandle32);
JNIEXPORT jfloatArray JNICALL
Java_daq_getpoint(JNIEnv *env, jobject obj)
jfloatArray theArray;
if (ADCurIndex >= 0)
/* Copy Data from memory to 32 bit memory buffer */
cbWinBufToArray(ADMemHandle, &ADValues[ADCurIndex], ADCurIndex ,2);
CurValue = ADValues[ADCurIndex];
CurValue2 = ADValues[(ADCurIndex + 1)];
else
CurValue = 0;
CurValue2 = 0;
jfloat tmp[2];
theArray = env->NewFloatArray(2);
cbToEngUnits(BOARD_NUM,ADRANGE,CurValue,&Voltage);
cbToEngUnits(BOARD_NUM,ADRANGE,CurValue2,&Voltage2);
tmp[0] = Voltage;
tmp[1] = Voltage2;
env->SetFloatArrayRegion(theArray, 0, 2, tmp);
return theArray;
}And this is the Java class:
* To change this template, choose Tools | Templates
* and open the template in the editor.
package fileiotest;
* @author Owner
public class dllinterface {
public native void startget();
public native float[] getpoint();
public native void stopget();
static {
System.loadLibrary("daqdll");//This is firstJNI.DLL
/*if generated by borland
System.loadLibrary("firstjni");//This is firstjni.dll
public static void start_daq()
dllinterface DI=new dllinterface();
DI.startget();
public static void stop_daq()
dllinterface DI=new dllinterface();
DI.stopget();
public static float[] get_data_point()
dllinterface DI=new dllinterface();
float newtempfloat[];
newtempfloat = DI.getpoint();
return newtempfloat;
} -
Call a method in VB dll from Java Web Application
Hi,
I'm trying to call a method of a VB dll, from a web application developing with J2EE. Is it possible without JNI? And, if it is not possible with a tool, can you help me with an example of JNI using?
Thank you
Marymaria_eg wrote:
I'm trying to call a method of a VB dll, from a web application developing with J2EE. Is it possible without JNI? Maybe using Runtime#exec() and rundll32.exe. Depends on the DLL which you want to call.
And, if it is not possible with a tool, can you help me with an example of JNI using?JNI tutorial: http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jni.html
JNI forum: http://forum.java.sun.com/forum.jspa?forumID=52 -
How to access data structures in C dll from java thru JNI?
We have been given API's( collection of C Functions) from some vendor.
SDK from vendor consist of:
Libpga.DLL, Libpga.h,Libpga.lib, Along with that sample program Receiver.h (i don't know its written in C or C++), I guess .C stnads for C files?
Considering that I don't know C or C++ (Except that I can understand what that program is doing) & i have experience in VB6 and Java, In order to build interface based on this API, I have two option left, Use these dll either from VB or Java.
As far as I know, calling this DLL in VB requires all the data structures & methods to be declared in VB, I guess which is not the case with Java (? I'm not sure)
I experiemnted calling these function from Java through JNI, and I successfully did by writting wrapper dll. My question is whether I have to declare all the constants & data structures defined in libpga.h file in java, in order to use them in my java program??
Any suggesstion would be greatly appreciated,
Vini1. There are generators around that claim to generate suitable wrappers, given some dll input. I suggest you search google. Try JACE, jni, wrapper, generator, .... Also, serach back through this forum, where there have been suggestions made.
2. In general, you will need to supply wrappers, and if you want to use data from the "C side" in java, then you will need java objects that hold the data. -
How to invoke a JAR from Java Swing application?
Hi,
I am trying to start a jar file from the swings application.
I am trying the following code,
String cmd[] = new String[]{"cmd", "java -jar TestJFreeChart.jar"};
try
Process run = Runtime.getRuntime().exec(cmd);
catch(Exception e)
{}Is anything wrong in the usage?First try:
"cmd /c java -jar app.jar" or cmd start, because it can't jsut run java.exe, it needs to be
passed to the cmd interpretor witch further calls java.exe, etc
Also read what stevejluke suggested. Its important to know if .waitFor or not.
You wont understand these until you read the tutorial. -
Hi everybody,
I am trying to call a dll from my java application. Pls tell me how to do it, I seached and found JNI. Is it true
pls help me and send me some examples
Thank you and have a nice dayjava_and_me wrote:
I am trying to call a dll from my java application. Pls tell me how to do it, I seached and found JNI. Is it trueYes, it is true. JNI is the way to go. You'll probably have to write some C code on your own as well, as the DLL is unlikely to be in the format expected by Java already.
pls help me and send me some examplesOf course. [Here you are|http://www.lmgtfy.com/?q=JNI+tutorial]. -
Calling existing C/C++ dll from Java Prog
Hi,
From within the Java code I want to use the
functionality of an existing C API. The dll's of C are available. Is it possible to directly call the C Api using Jni or some other technique or do I need to implement a native method in C which would Use the existing C Api to get the values and Pass them to the Java prog.
Istikhar.Is it possible to directly call the C Api using Jni...Depends on what you mean. You can't call it directly from java. You can use JNI, including C/C++ to call it.
-
Executing DLLs from Java using JNI vs Runtime.exec()
I am trying to understand the best way to execute a dll using java. The dll I am testing with takes a few input parameter. If I use JNI with System.loadLibrary("dll"); what do I need to do to pass the arguements in as well? Can I just add the arguements in the java code like private int xyz = "value"; and expect that the dll will accept them or is there special definitions I have to set up in the dll to make it work?
Alternatively I was looking at using Runtime to execute the dll by using Runtime.exec("dll param1 param2",env,filePath); Does anyone know if there are drawback to doing it this way vs. using JNI or is this just as efficient? Any help would be appreciated.You seem to be confused...
"execute a dll using java"
Unless I'm mistaken, a dll is not executable. A dll is a library of code. This code has (hopefully) some well-defined entry points (declared in a header file somewhere) which you must call in a C/C++ file. The arguments you pass to the dll will come from java through JNI.
As far as your understanding of this entire process, it is obviously confused beyond the scope of a simple reply. I recommend you read the examples and ALL of the documentation available here:
http://java.sun.com/docs/books/tutorial/native1.1/index.html
When you get the/an example running (or just set up to run) then post your code and comments here for more help.
Ian -
Call a C# dll from java is work only with the machine which is build C# dll
hi all,
I've built a VC++(win32 console dll app)..
Created a Java program to access the said VC++ dll
It was successful in the machine(say machine 1) which is created the VC++ dll..But Not work with machine2
n.b VC++ dll is accessing another VC#dll
If I combile the VC++ dll in machine2 then then its works fine with machine2 while access from java But not work with machine1
Problem comes when I run the same application in a different system where all the
needed visual studio files are installed...
I tried by create the VC++ dll with skipping the part of accessing VC# dll, then it works fine with anotther machine
NB: error accurs only when it is run on a different machine...
Error is:
# An unexpected error has been detected by HotSpot Virtual Machine:
# Internal Error (0xe06d7363), pid=4024, tid=4028
# Java VM: Java HotSpot(TM) Client VM (1.5.0_09-b01 mixed mode, sharing)
# Problematic frame:
# C [kernel32.dll+0x1eb33]
# An error report file with more information is saved as hs_err_pid4024.log
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
i've done "googling" with this error... but no one has come up with some satisfactory answer...
Pls help.....
conf. of both machine
Windows XP
jdk1.5.0_09, jre1.5.0_09
thanks in advance..Normally any system exception that occurs when working with JNI is caused by one of the following.
- pointer problems
- incorrect usage of another api
- bug in the api being used.
The last two are often still pointer problems.
The fact that it ones one machine and not another makes it more likely it is a pointer problem (in one or more of the above.)
A pointer problem cause cause the system to fail long after the point where the bug actually is (coded.) Different execution paths, such as running on different machines, means the bug will manifest itself differently.
Maybe you are looking for
-
HP Laserjet 2055D and Windows 8.1 - 49 ERR 3D90A44
Hello I have a brand new Laserjet Printer, the installed driver is a PCL6 - and when I want to print via USB, a blank paper is coming out and then I see this error message on the display: 49 ERR 3D90A44 I have already tried to install the newest firm
-
Troubles with LMS and Explorer
Goodmorning everybody, The past two months i've been trying to create a aw-piece that works in a LMS (SABA). Finally, technical speaking, it works. Still I have my doubts about it.... First, i've have used a java-code which communicates with the lms,
-
Hi Am having issue with iChat on my iMac, in which iChat wndow pop-ups everttime I log into the iMac. I have checked the User & Groups --> LoginItems and the iChat application is unchecked. Am not having similar issue with Macbook Pro. Can anyone hel
-
Using Destination Function in iProcurement
Hi, I have done the following: 1. Created xxCheckoutSummaryPG.xml ( since my requirement could not be done via personalization) 2. Imported xxCheckoutSummaryPG.xml to /xx/oracle/apps/icx/por/req/webui/xxCheckoutSummaryPG.xml 3. Created function XX_IC
-
I am using Call-manager 6.0.1b, a MGCP controlled Gateway.On the Gateway i have installed a NM-HD-2V with a Vic2-2FXS module. On this module i connect 2 analog phone with capability to display the Caller-ID. When i call the analog port from a ip phon