- Home /
Use Java library in Unity
Hi everybody,
I made a Java library and I would like to be able to use it in Unity 3D, and not only for Android devices, but for iOS as well.
I saw there are some tutorials on the Internet about doing a plugin for Android, but no one on how to use Java library in Unity.
I tried by converting my .jar in a .dll file. I can access my library methods, but it only works when I export my game for Windows devices. So, is there any other way to access my library methods on every device?
Thanks!
Answer by Jeff-Kesselman · Jun 05, 2014 at 02:50 PM
The other approach to cross platform is to do your Android and IOS coding in C# using Xamarin.
As long as you keep your library to the limits of what Unity knows, it will work in Unity or native on PC/OSX/Linux/Android/IOS and Unity.
To see an example of a cross platform project done this way, see: http://unseenu.wikispaces.com/AnyGUI
+1. Yeah. But while using Xamarin, staying in the limits is the main thing you need to remember. And this is one of the reasons why libgdx shifted to libgdx RoboV$$anonymous$$ backend from Xamarin. Plus there is also the reason of cost involved with Xamarin since not everyone can afford that cost. ;-)
Answer by HarshadK · Jun 05, 2014 at 11:00 AM
You might find this question on SO of some help: Can I access Java code from Unity?
O$$anonymous$$, thank you. But do you know if it's going to work on iOS as well? I have tested it on my Android device, and it works, I can access my classes and methods. I can't test it on iOS devices for now...
Thanks! :)
I'm not sure if it will work or not and I also don't have an iOS device. If you get to try it let us know the outcome for sure. :-)
Your answer
![](https://koobas.hobune.stream/wayback/20220613150832im_/https://answers.unity.com/themes/thub/images/avi.jpg)