Search Unity

Unity with Java

Discussion in 'Getting Started' started by Handen, Jul 4, 2017.

  1. Handen

    Handen

    Joined:
    Jul 4, 2017
    Posts:
    1
    Hello everyone! I am an beginner in programming, so I decided to learn Java first. Now, I create apps on Java in Android Studio, but I am fond of making games, and unity is the beast choice. The main question -- how can I create Android games in Unity on Java(I know it is possible)?
     
    anagrigo and SMARTERONE like this.
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You can't (effectively). C# is very similar to Java, so just use that.

    --Eric
     
    Kiwasi, Ryiah and JoeStrout like this.
  3. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,190
    Basically you need to compile your Java files into a JAR, use IKVM to convert the JAR into a DLL, place the DLL into your Assets folder, and then use C# to access the Java Code. Unless you already have an extensive codebase written in Java you're far better off simply learning C# since you'll need to use C# regardless of whether you choose to use Java.

    Additionally some of these links suggest you'll lose some of the debugging capabilities that would normally be available since the code isn't written in C#. For a beginner this would make the learning process considerably harder.

    https://www.ikvm.net/
    https://semitwist.com/articles/article/view/unity3d-supports-all-.net-clr-mono-languages
    http://answers.unity3d.com/questions/15308/can-i-access-java-code-from-unity.html
    https://forum.unity3d.com/threads/ideas-needed-for-debugging-using-java-code-inside-unity.49483/
    https://forum.unity3d.com/threads/building-project-with-ikvm-dlls-inside.101097/
     
    Last edited: Jul 4, 2017
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    I did Java with my first game engine. C# and Java are so similar in concept and syntax that it won't take you more then an hour to get up to speed with C#.

    You can do all that crazy stuff that @Ryiah mentions. But in reality you'll waste so much time on it that you are better off to just use C#.