How to setup a Ubuntu CraftBukkit Server (x64) running Java x64

Discussion in 'Bukkit Help' started by TnT, Jan 15, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    TnT Retired Staff

    Hello! My name is TnT and you may remember me from such how-to's as How to improve Minecraft Server Performance, and others that I'll probably write in the future, cause I find this shit fun.

    Today we are going to walk you through installing a fully functional Minecraft Server (latest version), running the latest Bukkit (Craftbukkit) mod (nightly build), using the latest x64 Java. You want to run x64 java so you can allocate as much RAM as your physical hardware allows, if you should so choose. You will not need the Gnome GUI and everything here will be laid out as newb friendly as possible. (If you think I can clarify something, please ask.)

    Step 1:
    Download Ubuntu Server 10.10 x64 and install. Installing Ubuntu itself goes a little outside the scope of this writeup, but its fracking easy. Base install is fine, but you should include OpenSSH server right away (I forgot.)
    If you forgot, once Ubuntu's booted up, run this command to install SSH
    Code:
    sudo apt-get install openssh-server
    Step 2:
    SSH into your Ubuntu server. First task is to install x64 Java. Downloading java through command line sucks, because Oracle is like that. If you're using Windows as your desktop, you can use winscp to upload the file to your Ubuntu machine in the temp directory (/tmp).

    Below we will create a new directory for your java install, move to that directory, copy the file from the /tmp directory (where you uploaded it via winscp), make that file executable, and then run the file for install.
    Code:
    sudo mkdir /opt/java
    sudo mkdir /opt/java/64
    cd /opt/java/64
    sudo cp /tmp/jre-6u24-linux-x64.bin .
    sudo chmod 755 ./jre-6u24-linux-x64.bin
    sudo ./jre-6u24-linux-x64.bin
    
    Now we need to set this java as the default java to use.
    Code:
    sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/64/jre1.6.0_24/bin/java" 1
    Step 3:
    Download and "install" craftbukkit.
    Below we will create a new directory for craftbukkit, change ownership to the user you want to run your server as, move to that directory, download craftbukkit and rename it.
    Code:
    sudo mkdir /opt/craftbukkit
    sudo chown <username>:<group> /opt/craftbukkit
    cd /opt/craftbukkit
    wget "http://ci.bukkit.org/job/dev-CraftBukkit/Recommended/artifact/target/craftbukkit-0.0.1-SNAPSHOT.jar"
    mv craftbukkit-0.0.1-SNAPSHOT.jar craftbukkit.jar
    
    Step 4:
    Write some simple startup scripts (personally, I use vi, but you can use whatever). Simple vi commands: i (insert), dd (delete current line), x (delete character), and esc to stop current command. :w (write), :wq (write and quit).
    Code:
    vi start.sh
    Script should look like this:
    Code:
    #!/bin/sh
    java -d64 -Xincgc -Xmx1024M -jar craftbukkit.jar nogui
    Now make that file executable:
    Code:
    chmod 755 start.sh
    Note: You can just run this command from the command prompt, but it's nice to have the script. (-Xincgc for 512M and over. Otherwise use -Xms<value>)

    Step 5:
    Startup your Minecraft server.
    Code:
    ./start.sh
    You will generate a new world, and all files needed to run a Minecraft server. The result is you now have a fully functional Minecraft server running the latest version of Craftbukkit. For more advanced features (running your world on a ramdisk, setting different values for java RAM allocation, etc, see this post on reddit).

    Advanced Stuff:
    Updating Craftbukkit upon launch and Remote Machine Backups.

    Updating Craftbukkit upon Launch:
    To update Craftbukkit upon launching your server, change your start.sh to reflect the following:
    Code:
    #!/bin/sh
    wget "http://ci.bukkit.org/job/dev-CraftBukkit/Recommended/artifact/target/craftbukkit-0.0.1-SNAPSHOT.jar"
    rm craftbukkit.jar
    mv craftbukkit-0.0.1-SNAPSHOT.jar craftbukkit.jar
    java -d64 -Xincgc -Xmx1024M -jar craftbukkit.jar nogui
    
    Remote Backups Using Rsync:
    This requires you have a separate backup server running an SSH server. First you want to setup SSH keys, so your authentication is seamless.

    How To Setup SSH keys. (It will ask for a password, leave this blank)
    Code:
    cd ~
    ssh-keygen -t rsa
    Now, you want to copy the resulting .pub file to the remote machine using ssh-copy-id.
    Code:
    ssh-copy-id -i .ssh/id_rsa.pub [email protected]
    Now you should be able to ssh without a password into that remote host.
    Code:
    ssh [email protected]
    Great, SSH keys are all setup. Close your connection to the remote host by typing exit.

    Now, write a script to perform the rsync operation.
    Code:
    cd /opt/craftbukkit
    vi backupscript.sh
    The script should look like this:
    Code:
    #!/bin/bash
    active=`pidof rsync`
    if [ -z $active ]; then
            /usr/bin/rsync -avz --progress --rsh='ssh -p22' /opt/craftbukkit [email protected]:/remote/backup/directory
    else
    echo "Backup already running, aborting operation."
    exit 0
    fi
    exit 0
    
    Now we need to add that as a cron job.
    Code:
    crontab -e
    To backup every 30 minutes, this is the line you should add:
    Code:
    30 * * * * /opt/craftbukkit/backupscript.sh
     
  2. Offline

    cnx4mia123

    how come when i try to run the ./start.sh it says permission denied?
     
    TnT likes this.
  3. Offline

    TnT Retired Staff

    do a
    Code:
    ls -la /opt/craftbukkit
    and paste the results

    I see my mistake. Do this:
    Code:
    chown <username>:<group> /opt/craftbukkit
    Your group will be the same as your username.
     
  4. Offline

    OneArmManny

    Followed your steps.. everything works great until I go to run the server:
    Code:
    [email protected]:/opt/craftbukkit$ ./start.sh
    --2011-01-15 17:26:55--  http://artifacts.lukegb.com/artifactory/plugins-snapshot/org/bukkit/craftbukkit/0.0.1-SNAPSHOT/craftbukkit-0.0.1-SNAPSHOT.jar
    Resolving artifacts.lukegb.com... 67.228.153.21
    Connecting to artifacts.lukegb.com|67.228.153.21|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 981594 (959K) [application/java-archive]
    Saving to: `craftbukkit-0.0.1-SNAPSHOT.jar'
    
    100%[======================================>] 981,594      717K/s   in 1.3s
    
    2011-01-15 17:26:56 (717 KB/s) - `craftbukkit-0.0.1-SNAPSHOT.jar' saved [981594/981594]
    Exception in thread "main" java.lang.NoClassDefFoundError: craftbukkit/jar
    Caused by: java.lang.ClassNotFoundException: craftbukkit.jar
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:266)[/B]
    Could not find the main class: craftbukkit.jar. Program will exit.
    
    Is something just wrong with this build? or is maybe the renaming breaking it?
     
  5. Offline

    cnx4mia123

    like im using Cent0s on a linux vps so yeah : [[email protected] ~]$ ls -la /home/minecraft/craftbukkit.jar
    -rw-rw-r-- 1 minecraft minecraft 979110 Jan 16 00:21 /home/minecraft/craftbukkit.jar
    what do i do know? i still get permission denied when do./start.sh
     
  6. Offline

    TnT Retired Staff

    I do this currently for my server.

    Run both of these commands and paste the output.
    Code:
    java -version
    cat /opt/craftbukkit/start.sh
    --- merged: Jan 15, 2011 10:48 PM ---
    Can you do an ls -la on /home/minecraft/start.sh please?
     
  7. Offline

    OneArmManny

    Code:
    [email protected]:~/minecraft/bin$ java -version
    java version "1.6.0_20"
    OpenJDK Runtime Environment (IcedTea6 1.9.2) (6b20-1.9.2-0ubuntu2)
    OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)
    [email protected]:~/minecraft/bin$ cat /opt/craftbukkit/start.sh
    #!/bin/sh
    wget "http://artifacts.lukegb.com/artifactory/plugins-snapshot/org/bukkit/craftbukkit/0.0.1-SNAPSHOT/craftbukkit-0.0.1-SNAPSHOT.jar"
    rm craftbukkit.jar
    mv craftbukkit-0.0.1-SNAPSHOT.jar craftbukkit.jar
    java -Xms4096M -Xmx4096M craftbukkit.jar nogui
    
    Thanks for the quick reply :)
     
  8. Offline

    cnx4mia123

    sure here you go:[[email protected] ~]$ ls -la /home/minecraft/start.sh
    -rw-rw-r-- 1 minecraft minecraft 57 Jan 16 00:28 /home/minecraft/start.sh
     
  9. Offline

    TnT Retired Staff

    Try updating your Java, you're a few versions behind. Also, you're using OpenJDK, not Sun Java, so you may be having problems there.

    Here is mine:
    Code:
    [email protected]:~$ java -version
    java version "1.6.0_23"
    Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
    Java HotSpot(TM) 64-Bit Server VM (build 19.0-b09, mixed mode)
     
  10. Offline

    cnx4mia123

    and how do i fix mine :p
     
  11. Offline

    TnT Retired Staff

    Run this and then try it again:
    Code:
    chmod 755 /home/minecraft/start.sh
     
  12. Offline

    OneArmManny

    It's weird.. I've downloaded the correct java.. (twice, hah) - and I did the
    sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/64/jre1.6.0_23/bin/java" 1
    to make it "use that java" - and still afterwards when I do the java -version I get the same results as before... gonna try rebooting :confused:
     
    TnT likes this.
  13. Offline

    cnx4mia123

    thankx
    --- merged: Jan 15, 2011 11:20 PM ---
    WHAT?? When i tryed to run it know this happens"

    Exception in thread "main" java.lang.NoClassDefFoundError: craftbukkit-0/0/1-SNAPSHOT/jar
    Caused by: java.lang.ClassNotFoundException: craftbukkit-0.0.1-SNAPSHOT.jar
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
    Could not find the main class: craftbukkit-0.0.1-SNAPSHOT.jar. Program will exit.
     
  14. Offline

    TnT Retired Staff

    Try removing your OpenJDK first. Check this.
     
  15. Offline

    OneArmManny

    Thanks! Will do.. but now it looks like the other guy in this thread has the same error... maybe it's just a bug in the build. kmod runs fine... :X
     
  16. Offline

    TnT Retired Staff

    Run both of these commands and paste the output.
    Code:
    java -version
    cat /opt/craftbukkit/start.sh
     
  17. Offline

    cnx4mia123

    java version "1.6.0_17"
    OpenJDK Runtime Environment (IcedTea6 1.7.5) (rhel-1.16.b17.el5-x86_64)
    OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)
    [[email protected] ~]$ cat /opt/craftbukkit/start.sh
    cat: /opt/craftbukkit/start.sh: No such file or directory
    [[email protected] ~]$ cat /home/minecraft/start.sh
    #!/bin/sh
    java -Xms2030M -Xmx2560M craftbukkit-0.0.1-SNAPSHOT.jar nogui
     
  18. Offline

    TnT Retired Staff

    New build is out - (#41), but the other guy is also using OpenJDK, and I've heard that can be a real pain with Minecraft.
     
  19. Offline

    OriginalSyn

    Hey guys,

    Minecraft and CraftBukkit need Sun Java. If you're using OpenJDK's JRE it's not going to work.
     
    TnT likes this.
  20. Offline

    TnT Retired Staff

    Same advice as I gave OneManArmy. Uninstall your OpenJDK and install Sun Java. OpenJDK can be a real pain with Minecraft.
     
  21. Offline

    cnx4mia123

    im new to linux so its rpm -e openjdk?
     
  22. Offline

    OneArmManny

    Just a side note... at the end of the install this time around I did this:
    sudo update-alternatives --set java /opt/java/64/jre1.6.0_23/bin/java
    to make it the default java installation and now it's good to go. - sort of:

    Code:
    Exception in thread "main" java.lang.NoClassDefFoundError: craftbukkit/jar
    Caused by: java.lang.ClassNotFoundException: craftbukkit.jar
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class: craftbukkit.jar.  Program will exit.
    [email protected]:/opt/craftbukkit$ java -version
    java version "1.6.0_23"
    Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
    Java HotSpot(TM) 64-Bit Server VM (build 19.0-b09, mixed mode)
    
    
     
    TnT likes this.
  23. Offline

    TnT Retired Staff

    I haven't ran RedHat in a long time, or centos either. you can try following this site, (command below) or maybe try uninstalling using yum.
    Code:
    rpm -e java-1.6.0-openjdk
    --- merged: Jan 15, 2011 11:45 PM ---
    Can you give me an ls -la on your /opt/craftbukkit dir?
     
  24. Offline

    OneArmManny

    Sho:
    Code:
    [email protected]:/opt/craftbukkit$ ls -la
    total 1944
    drwxr-xr-x 2 chris chris   4096 2011-01-15 18:38 .
    drwxr-xr-x 6 root  root    4096 2011-01-15 17:18 ..
    -rw-r--r-- 1 chris chris 981890 2011-01-15 18:00 craftbukkit-0.0.1-SNAPSHOT.jar.1
    -rw-r--r-- 1 chris chris 981890 2011-01-15 18:00 craftbukkit.jar
    -rwxr-xr-x 1 chris chris    261 2011-01-15 17:52 start.sh
    -rw------- 1 chris chris  12288 2011-01-15 17:23 .start.sh.swp
    
     
  25. Offline

    TnT Retired Staff

    Delete the files and try running ./start.sh again.
    Code:
    rm craftbukkit.*
     
  26. Offline

    OneArmManny

    Code:
    Exception in thread "main" java.lang.NoClassDefFoundError: craftbukkit/jar
    Caused by: java.lang.ClassNotFoundException: craftbukkit.jar
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class: craftbukkit.jar.  Program will exit.
    [email protected]:/opt/craftbukkit$ ls -la
    total 984
    drwxr-xr-x 2 chris chris   4096 2011-01-15 18:52 .
    drwxr-xr-x 6 root  root    4096 2011-01-15 17:18 ..
    -rw-r--r-- 1 chris chris 981890 2011-01-15 18:00 craftbukkit.jar
    -rwxr-xr-x 1 chris chris    261 2011-01-15 17:52 start.sh
    -rw------- 1 chris chris  12288 2011-01-15 17:23 .start.sh.swp
    
     
  27. Offline

    TnT Retired Staff

    Run this:
    Code:
    pwd
    If the output is not /opt/craftbukkit, change to the /opt/craftbukkit directory:
    Code:
    cd /opt/craftbukkit
    Then run your ./start.sh again.

    Please paste the full output, including your initial command.
     
  28. Offline

    OneArmManny

    Code:
    [email protected]:/opt/craftbukkit$ pwd
    /opt/craftbukkit
    [email protected]:/opt/craftbukkit$ ./start.sh
    --2011-01-15 19:02:01--  http://artifacts.lukegb.com/artifactory/plugins-snapshot/org/bukkit/craftbukkit/0.0.1-SNAPSHOT/craftbukkit-0.0.1-SNAPSHOT.jar
    Resolving artifacts.lukegb.com... 67.228.153.21
    Connecting to artifacts.lukegb.com|67.228.153.21|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 981890 (959K) [application/java-archive]
    Saving to: `craftbukkit-0.0.1-SNAPSHOT.jar'
    
    100%[======================================>] 981,890      713K/s   in 1.3s
    
    2011-01-15 19:02:03 (713 KB/s) - `craftbukkit-0.0.1-SNAPSHOT.jar' saved [981890/981890]
    
    Exception in thread "main" java.lang.NoClassDefFoundError: craftbukkit/jar
    Caused by: java.lang.ClassNotFoundException: craftbukkit.jar
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
    Could not find the main class: craftbukkit.jar.  Program will exit.
    [email protected]:/opt/craftbukkit$
    
     
  29. Offline

    cnx4mia123

    I cant install java idk how can someone provide the download link for it x64bit linux?
     
  30. Offline

    TnT Retired Staff

    http://www.java.com/en/download/manual.jsp
    --- merged: Jan 16, 2011 12:17 AM ---
    I SEE IT!

    Change this:
    Code:
    java -Xms4096M -Xmx4096M craftbukkit.jar nogui
    To This:
    Code:
    java -Xms4096M -Xmx4096M -jar craftbukkit.jar nogui
    Sorry guys, I fucked up the initial instructions. They've been fixed.
     
    Retribution3000 likes this.
Thread Status:
Not open for further replies.

Share This Page