Click here to Skip to main content
15,882,114 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have certain java classes which i have exported as a .jar file in eclipse. Further, I have created a java binding library project in Xamarin and added the .jar file to the jar folder. I need to create another android app project in xamarin and reference the library project into it and use the library into classes in the android app project.

I need to know whether is this the right way to convert an android project on eclipse into c# android in xamarin
Posted

You can't directly reference Java classes from the .NET Framework, but you can run Java code from a .NET application.

You do it using a tool called IVKM.Net. IVKM.NET includes an application called ikvmc. You can view the documentation for it here http://www.ikvm.net/userguide/ikvmc.html[^]

To use it compile your java code into a Jar file.

Then run the ikvmc program:

ikvmc myJavaCode.jar

If you jar code contains a main() entry function then it will be converted into an EXE than be executed and run on the CLR. If it doesn't then it will be converted into DLL's. These DLL's can be added to your Visual Studio project as References in the usual manner.
 
Share this answer
 
Hi,

Its not possible to covert Java to Xamarin in Xamarin IDE..

http://developer.xamarin.com/guides/android/advanced_topics/java_integration_overview/[^]

Need to use some converter tool and also make sure that every class, methods, properties, interface etc follow the naming constraints...

http://developer.xamarin.com/guides/android/advanced_topics/java_integration_overview/porting_java_to_csharp/[^]

You can also use Java Code directly in Xamarin and invoking the JNI

See source code from the below link

http://developer.xamarin.com/samples/JniDemo/[^]

Thanks,

Ullas krishnan
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900