cheezyguy5
Posts: 8
Joined: Wed Jan 08, 2014 2:53 pm

Convert Java to C?

Wed May 07, 2014 6:05 pm

I've been reading about running a minecraft server on a Pi, and it seems the main reason it's so slow is that it's running in a Java Variable Runtime Environment. Wouldn't it be possible, at all, to convert the minecraft_server.jar to C code? If so, wouldn't it be able to run directly on the Pi without an emulated environment?

User avatar
tedhale
Posts: 114
Joined: Thu Sep 20, 2012 4:52 pm
Location: Williamsburg, VA, USA
Contact: Website

Re: Convert Java to C?

Wed May 07, 2014 7:45 pm

You would have to de-compile the java source from the jar file, then convert all the java code to C, including replacements for all libraries used. That would be a LOT of work.
But, yes, assuming you did all of that, it would run in native mode and be faster. My guess is that it would only be a little faster.
- Ted B. Hale
http://raspberrypihobbyist.blogspot.com

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 24162
Joined: Sat Jul 30, 2011 7:41 pm

Re: Convert Java to C?

Wed May 07, 2014 7:46 pm

Might be worth a search to see if this has already been done.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

ghans
Posts: 7878
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: Convert Java to C?

Thu May 08, 2014 7:28 am

Instead going down that dead end (so far i know Minecraft
is obsfucated via ProGuard or something else) , just try it
with the newest Oracle Java 8 JRE which is available for the Pi
free of cost. It is way faster than OpenJDK and faster than
Oracles Java 7 , too. If that isn't enough , use a desktop
to host your server.


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

vyalmicro
Posts: 1
Joined: Fri May 09, 2014 3:38 pm
Location: India
Contact: Website

Re: Convert Java to C?

Fri May 09, 2014 3:53 pm

It isn't that simple. First of all you would need to decompile to get the Java code back first of all. I don't think it would be legally very great idea. Given you successfully decompiled and generated the Java code then it would be almost impossible job to translate Java to C. You'll need to implement the object oriented features of Java in C. Use already existing formal grammar of Java and then use flex/bison to generate a intermediate code. Then translate that intermediate code into C. You'll then have to compile all needed libraries too by your compiler and make sure it works well with your new compiler.
Ready to do so much work to only make Minecraft work at Pi? I doubt it would be too much for what it is worth.

Return to “C/C++”