timurlenk
Posts: 2
Joined: Mon Aug 27, 2012 8:36 am

Need Help - Java into machine code

Mon Aug 27, 2012 8:43 am

I am trying to host a Minecraft server on the RPi using as less resources as possible. Right now I want to compile the Minecraft server source code, which I decompiled using MCP, into machine code. I read I could use gcj for it which is supposed to be integrated into gcc, but I have gcc (version 4.6.3-8+rpi1) and I don't have gcj as far as I can tell. How can I get gcj and what am I supposed to do afterwards?

User avatar
joan
Posts: 14588
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Need Help - Java into machine code

Mon Aug 27, 2012 9:11 am

To install a package try

sudo apt-get install package-name

In your case try

sudo apt-get install gcj

I don't know how you'd use it for Minecraft. Does the article which referenced gcj give no idea?

p.s. if you are not sure of a package's name try

sudo apt-cache search some-letters-of-package-name

to give a list of likely candidates.

User avatar
xranby
Posts: 539
Joined: Sat Mar 03, 2012 10:02 pm
Contact: Website

Re: Need Help - Java into machine code

Mon Aug 27, 2012 1:56 pm

The correct way to use GCJ:

#First install gcj and ecj
sudo apt-get install gcj-jdk

#example 1: compile a HelloWorld with a known main class
gcj -o hello HelloWorld.java --main=HelloWorld
#then run the binary
./hello

#example 2: compile a standalone Java .jar or .class with a known main class
wget http://math.nist.gov/scimark2/scimark2lib.jar
gcj -o scimark2 scimark2lib.jar --main=jnt.scimark2.commandline
./scimark2

# complexity increases when you try to compile a .jar that in turn depend on other jars.
# i here use -findirect-dispatch to allow the compilation to continue in situations
# when the craftbukkit.jar contains references to classes in external jars, like ant and lucene,
# that can not be found at compiletime.
#
# If you have a lot of memory and then you should be able to compile the bukkit minecraft server
# by running the following:
gcj -findirect-dispatch craftbukkit.jar -o craftbukkit --main=org.bukkit.craftbukkit.Main
# unfortunately the raspberry pi do not have enough RAM to
# complete the static compilation of this large server application.

The complete manual to gcj is found here:
http://gcc.gnu.org/onlinedocs/gcj/
good luck!
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby

timurlenk
Posts: 2
Joined: Mon Aug 27, 2012 8:36 am

Re: Need Help - Java into machine code

Mon Aug 27, 2012 5:07 pm

I did check the GNJ manual before but I didn't understand much from it so I didn't know where to look, but your post explains everything I need.
Thanks a lot!

Return to “Other programming languages”