I want develop a GUI with Visual Basic but I want access to Java Objects
from this GUI. I know this url that talks about that through a bridge
(http://www.linar.com/jintegra/doc/index.html). But now I'd like to know
if I can do that using JNI.
Thanks.
--
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Pablo Alonso Sande.
pal...@denodo.com
Denodo Technologies, S.L.
Real 20, 1º A. 15003 A Coruña
Telf: +34 981 100200
Fax: +34 981 100205
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
Welp, I just finished about two hours of research on just this question
on USENET (from deja.com), my VB IDE, CodeWarrior, and elsewhere, and
here's my own personal conclusion: You're much better off just calling
command lines from VB and having Java write out your results to a file
or spitting them back over a socket (via Winsock). I've got a little
code below in VB to show how to use the command line, in case you're
wondering.
I fished through quite a few sites that did things similar to what I
think you're looking for, and none seemed worth the benefit of figuring
out exactly how the pieces fell together or worth the dough to purchase
a solution that was easy to figure out!
Here are some links:
JNI -- http://java.sun.com/products/jdk/1.2/docs/guide/jni/index.html
--
http://java.sun.com/docs/books/tutorial/native1.1/concepts/index.html
JNI looks awful good for relatively savvy C/C++ programmers.
Regrettably, I don't fall into that category (yet).
JET -- http://www.excelsior-usa.com/jet.html
-- http://www.excelsior-usa.com/jetfaq.html#interop1
JET looks cool at first -- it actually COMPILES Java apps into .exe's
and .dlls. Unfortunately it looks like they can't be called from other
apps quite like you'd expect. I don't think.
JACOB -- http://users.rcn.com/danadler/jacob/
From the site, "Now you can call COM Automation from any Win32 Java VM
using JNI" If I'm not mistaken, JACOB is pretty cool but works from
the wrong direction. You can call COM objects from Java with JACOB but
not the other way round. Seems backwards to me. I'd rather be able to
take the Java engine I've made and wrap a customized VB GUI around
that -- and have that GUI invoke some VB-specific jive that's easy as
all get-out to program in VB versus Java. That's why we're using VB to
begin with, right? Not to build engines, but to link other engines
together! Still, JACOB is open-source, and pretty
proverbially "k3wl". :^D
There are also a number of pretty decent tutorials of how to use JNI
for all these things I want to do, but they're all (regrettably) for
C/C++. There's a whole chapter from a book about JNI up for the taking
at java.sun.com.
Back to the solution front... Apparently some people are writing up
C/C++ "go-betweens" to hack up Java and VB:
http://x53.deja.com/getdoc.xp?
AN=531052952&CONTEXT=973300582.1559691287&hitnum=44
>I can only give you my suggestion. We are using a set of java classes
>from VBA by wrapping java in a C++ COM component, which uses JNI to
>access java. It would look something like this:
>
>JAVA <--jni--> C++ <--com--> VBA
>
>I can't tell you if this is the right way of doing things but it's our
way.
>
>Claus Poulsen
Seems like a real hack to me, but hacks aren't always bad imo (as I
show by my hack of a recommendation/example below)!
Anyhow, here's my current workaround. Call your Java app from the
command line using VBA.Interaction.Shell. Here's the code. I have a
form called Form1 with a command button called Command1 in the middle.
Command1's click event is all I'm worried about.
==========================
Option Explicit
Private Sub Command1_Click()
Call VBA.Interaction.Shell("java -cp AppClassesDBG.jar pCopy",
vbNormalFocus)
End Sub
==========================
Concerns: Remember where you're pointing this thing. If you run the
app from within the VB IDE, you're not going to find the jar file
unless it's in there with the VB6.exe. Make Project1.exe (named
whatever you'd like, of course) that's in the same dir as the jar file
and you're rolling.
I've also seen some weird activity with System.out.print's when I've
called a java app using the VBA.Interaction.Shell jive. But all in
all, this is a very VERY easy and straightforward way of using engines
created in Java from VB. Not to mention a very free way to do so. Not
the most efficient use of processor cycles, certainly, but the most
efficient use of my time until I'm worried about the slow down of
writing the results to a file.
Hope that helps!
Ruffin Bailey
(remove the $P4M to email ("SPAM"))
--
Ruffin.Bailey@noaa$4AM.gov | Database Management Systems Group
TPMC.com contractor | NOAA Coastal Services Center
http://www.csc.noaa.gov |
"This may be the fault of the interpreter, in which
case HE is the hippopotamus." Boris Yeltsin, 60 Minutes
Sent via Deja.com http://www.deja.com/
Before you buy.
[skip]
> Here are some links:
>
> JET -- http://www.excelsior-usa.com/jet.html
> -- http://www.excelsior-usa.com/jetfaq.html#interop1
> JET looks cool at first -- it actually COMPILES Java apps into .exe's
> and .dlls. Unfortunately it looks like they can't be called from
other
> apps quite like you'd expect. I don't think.
>
You may use Invocation API that is part of JNI spec to call JET-compiled
DLLs. See JET\samples\Invocation. That's in C I know, but it should be
failry easy to write a C wrapper that may be invoked from VB.
----------------------------------------------------------
Dmitry V. Leskov
Excelsior, LLC
http://www.excelsior-usa.com
http://www.iceteagroup.com/products/jasper/jasper.htt
Regards,
Frank
Ice Tea Group, LLC
In article <8tvu5k$gss$1...@nnrp1.deja.com>,
Rufbo <wrba...@my-deja.com> wrote:
to start the packager:
java -cp %JAVA_HOME%/lib/tools.jar; sun.beans.ole.Packager
(mail me if it wasnt right..)
-provided that you use Windows ;) ,jdk1.3 and have
set you JAVA_HOME variable...
If you want the other way round, calling ActiveX from Java
take a look at Bridge2Java somewhere at alphaworks.ibm.com(has a example
of a swing application with an embedded IExplorer)
or Jintegra at www.jintegra.com
"Pablo Alonso Sande" <PAl...@denodo.com> wrote in message
news:3A031662...@denodo.com...
> Hello guys,
>
> I want develop a GUI with Visual Basic but I want access to Java Objects
> from this GUI. I know this url that talks about that through a bridge
> (http://www.linar.com/jintegra/doc/index.html). But now I'd like to know
> if I can do that using JNI.
>