Link to home
Start Free TrialLog in
Avatar of Michael_D
Michael_DFlag for Canada

asked on

Using Java Classes (.jar) from VB.NET/C#

Hi Experts.
I just wonder if it is possible to use Java Classes from VB.Net/C#.
I guess I need to create Wrapper class in J# , compile it into Dll and then refer to this Dll from VB/C# project.
Will this aproach work?
Any information about this issue will be very helpful becouse my knowledge of Java is close to nothing :)

Thanks,


Michael
Avatar of The_Biochemist
The_Biochemist

Sorry to say this but... You would probably have to re-write most of it in j# anyway to ensure the code is well managed and to make it bug free, that beggs the further question if you are used to VB/C# then is it more sensible to re-write it in one of those languages instead?

you may want to wait a while to see if others respond differently but I wouldn't hold your breath unfortunately!
Avatar of Michael_D

ASKER

The problem is I cannot change Java sources. I have to use it as is . (some API functions to interface with third-part application)
Any idea?
I'm gonna backtrack as found a site that talks about the migration of J++ and vj++ apps to J# or c#.Net (1) and they site a Microsoft developer center designed specifically for automatic migration of those apps (2). There are also shed loads of links on that topic within the MS dev center so have a look. If it is anything like the use of COM components within the .NET world it probably just creates a wrapper for you but i'm not sure.

1)  http://www.javaworld.com/javaworld/jw-01-2003/jw-0103-migration.html

2)  http://msdn.microsoft.com/vstudio/downloads/tools/jlca/default.aspx

Good Luck
P.S.

This talks about creating a J++ wrapper as oposed to converting an entire project.

http://support.microsoft.com/default.aspx?scid=kb;en-us;818429
Easiest way is to use one of the bridge available in Market commerically.
Microsoft recomemnds three options.
1. http://www.jnbridge.com/
2. http://j-integra.intrinsyc.com/


For reference http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/jdni_ch04.asp
The_Biochemist:

Your 3rd link is very close to my needs. But as I mentioned before  I have no experience with java. Could you explain some issues in this article?
For example  it says:
<Quote>
1. Compile the Java-language or COM component by using the Visual J# .NET command-line compiler (Vjc.exe). For example, type the following at a command prompt, and then press ENTER to compile the code:
vjc /target:library JavaSources
</Quote>

I dont have the sources. Is result of this compilation .JAR file that I have?  

This article about migration of VJ++ to J#. Is it Ok that my java class was created on Borland enviroment?

Thank you
ASKER CERTIFIED SOLUTION
Avatar of The_Biochemist
The_Biochemist

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The_Biochemist:

Sorry for delay, prioreties has been changed :)

I tryed ActiveX Bridge as you recomend in your last post. but unfortunatelly after I select the .jar file and have to choose JavaBean to convert into ActiveX Component. there is NO JavaBeans shown. Is it possible? I repeat I don't have sources so I can't change anything with .jar file

Any ideas?
Unfortunately I haven't solved my problem but I guess that my .Jar class doesn't  support this "bridge" thing.
Anyway, IMO this thread should be stored in EE database as solved solution