Can you use Java libraries in a VB.net program?
Asked Answered
M

8

5

I'm wondering if a Java library can be called from a VB.net application.

(A Google search turns up lots of shady answers, but nothing definitive)

Martyrology answered 30/9, 2008 at 13:14 Comment(0)
D
4

No, you can't. Unless you are willing to use some "J#" libraries (which is not nearly the same as Java) or IKVM which is a Java implementation that runs on top of .NET, but as their documentation says:

IKVM.OpenJDK.ClassLibrary.dll: compiled version of the Java class libraries derived from the OpenJDK class library with some parts filled in with code from GNU Classpath and IcedTea, plus some additional IKVM.NET specific code.

So it's not the real deal.

Duckling answered 30/9, 2008 at 13:18 Comment(2)
+1 for IKVM we use it to nicely communicate between our .NET UI and Java server via RMI stubs wrapped by IKVM assemblies.Tuneberg
Indeed, IKVM does the job nicely as long as the components aren't AWT/Swing based.Chancy
L
3

I am author of jni4net, open source intraprocess bridge between JVM and CLR. It's build on top of JNI and PInvoke. No C/C++ code needed. I hope it will help you.

Loincloth answered 31/10, 2009 at 18:41 Comment(0)
C
2

You can call Java from .NET if you wrap it in some form to make it accessable and the easiest way is typically to use a Runtime bridge like

http://www.jnbridge.com/

Other way is to wrap your API with java webservices.

check this also http://www.devx.com/interop/Article/19945

Colleague answered 30/9, 2008 at 13:20 Comment(0)
H
1

Nothing out of the box.

Most java/.net interop that I know uses web services.

Hedda answered 30/9, 2008 at 13:19 Comment(0)
B
1

If you can create COM components with Java, you can use tlbimp to create an interop assembly for using in VB.Net.

If can create standard DLLs that can be used from C++ with Java, you can write P/Invoke declarations and call them from VB.Net.

If you can create a web service with Java, you can generate proxy class from the WSDL and call it from VB.Net.

In any case, chances are the Java component will live in a separate process. I doubt you can load both the Java VM and the CLR in the same process.

Barlow answered 30/9, 2008 at 13:19 Comment(0)
E
1

If you have the source code and compile it using the J# compiler, then the answer is yes. If you want to call any pre-Java 2 (aka 1.2) libraries, then these are included pretty much verbatim with J#. More recent stuff is going to be tricky though (i.e., it's not there).

An example where this is used commercially are the yFiles graph layout algorithms from yWorks. These were originally just a Java library, but for the past few years they've been offering a .NET version, which is just the Java version compiled with Visual J#.

It's not without problems, and there are some limitations that you can't get around, but it can be done. So... unfortunately this answer looks pretty shady as well.

Emmett answered 30/9, 2008 at 13:19 Comment(0)
O
0

You could use JNI to instantiate a virtual machine and then use Java Classes. It will be some fun, though, because you would need to use C++ as a bridge between VB.Net and Java.

This article in java world has a quick tutorial on how to use Java from C++ and viceversa.

http://www.javaworld.com/javaworld/javatips/jw-javatip17.html

Omission answered 30/9, 2008 at 13:20 Comment(0)
C
0

If you have the source, Visual Studio will let you convert Java code into c#.

Chasidychasing answered 30/9, 2008 at 13:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.