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
LVL 13
Michael_DAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The_BiochemistCommented:
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!
0
Michael_DAuthor Commented:
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?
0
The_BiochemistCommented:
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
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

The_BiochemistCommented:
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
0
softenggCommented:
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
0
Michael_DAuthor Commented:
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
0
The_BiochemistCommented:
Right had another trawl of the net...

http://www.reallyusefulcomputing.com/tutorials.php?t=3&p=1 has a tutorial on the subject which in step 4 - http://www.reallyusefulcomputing.com/tutorials.php?t=3&p=4 -  converts a JAR to an Active X control and then the active X control can be used in your .net code... hopefully?!?

There is also another comment in a discussion group which references the tutorial above... not sure of it's relevance but may make sense in context. http://forum.java.sun.com/thread.jspa?forumID=40&messageID=2639298&threadID=532297
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Michael_DAuthor Commented:
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?
0
Michael_DAuthor Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.