?
Solved

Calling a VB active dll from Java

Posted on 2003-11-25
12
Medium Priority
?
1,058 Views
Last Modified: 2012-08-13
I am in a very unusal situation.

I have a java application that I use JACOB to call an activex program. That's all good but the activex quit function only hides the program and leaves it running in the backgound in task manager (we are using an NT environment). I need to kill the darn thing, and before anyone asks, there are no other quit or kill functions in the activex object.

So far, I have created vb code that calls kernel32.dll for killing and turned it into an activex dll. I tried using JACOB and have not succeeded. Maybe I  have to register the dll somehow? Forgive me, vb and dlls are not my strong point.

Here is an example of what happens

      Variant[] vari = {};
      Variant vari2 = new Variant();
      comp = new ActiveXComponent(ID);
      vari2 = comp.invoke("theMethod",vari);

And i get this exception message
            Invoke of: theMethod
            Source: Project1
            Description: Object required

Gonna look into JNI... but is that only c++????

I may be going down the completely wrong path. Alternatives are welcome! And if you know a way to talk to the kernel32.dll. Any links to any code, sites, anything would help. Cannot seem to find what I am looking for anywhere.
I have the VB code to call the kernel32.dll. Got it from the microsoft website. I can send it if needed. I have tested the code and it works fine.
Help!
boog
0
Comment
Question by:imnotahomey
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
12 Comments
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9822913
There is a commercial product called jintegra (http://www.linar.com) that
makes what you want to do really easy.

There are some royalties associated with the product, but they are not as
bad as they might have been. It is comprised of a library that forms a
bridge from Java to COM/ActiveX, and the library is 100% pure java. Their
web site has a downloadable fuly functioning trial version, and they have
lots of really good tutorial material.
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9822928
EZ JCom lets you call COM objects from Java.

Using EZ JCom is very straightforward. You give it a COM object, and it will generate a set of Java source files, plus a command file for compiling these Java source files. Your Java program can then use these to instantiate COM objects, to get their interfaces, to call methods provided by the COM objects, and to register event listeners for any events the COM objects might generate. EZ-JCom also extracts the COM documentation and places it in a Javadoc format, to help you understand how your COM object works and how to use it.

If your COM object is an ActiveX control that needs to have a visual display, EZ JCom will let you embed it in a Swing or AWT program.

Their site:

http://www.ezjcom.com/google.html
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9822945
if you think there is a problem with registering the activex dlls the do like this

Runtime.exec("regsvr32     yourdll.ocx");
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 15

Accepted Solution

by:
dualsoul earned 1500 total points
ID: 9822972
> Gonna look into JNI... but is that only c++???
hm...i'm not really understand your problem, but when i was need to call some activex from java, i was writing JNI method in C++, which calls ActiveX, and then use this method from java. All works fine.
     
0
 

Author Comment

by:imnotahomey
ID: 9822988
Looks like EZ JCom lets me do exactly what I want... except I will have to ask the client to pay.
The client is not going to want to spend the money when they can click Ctrl-Alt-Delete to quit the program.
Might have to look at talking directly to kernel32.dll
any suggestions?
0
 
LVL 15

Expert Comment

by:dualsoul
ID: 9822998
i think, if you need only call once your AciveX, there are no sence in frameworks, just implement it in JNI by hand, it's very easy.
  But if you need to use COM classes, as Java Classes and vice versa, thah - yes, you some framework, which allow you transparently call COM.
0
 
LVL 15

Expert Comment

by:dualsoul
ID: 9823014
look, please expalin one more what's problem?
you call ActiveX from Java, and when it's finished, it's hide your Java program?
0
 

Author Comment

by:imnotahomey
ID: 9823078
There is another program (not a java program) i call from java. When I quit the program, it disappears, but still shows in the task manager. I need to kill it in task manager.
0
 

Author Comment

by:imnotahomey
ID: 9823097
I think I will try and call the dll from some c code and use jni.
I have only created one method in the dll that I need to call.
Know of any examples of calling a dll in c or c++?
0
 

Author Comment

by:imnotahomey
ID: 9823771
Thank you all for your help.
It has been most useful.
Too bad I couldn't accept more than one comment.
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 9823778
i think only  EZ JCom helps your problem
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question