Compiling Nukkit
Note: You don't have to compile Nukkit yourself unless you want to modify the code. You can find the latest precompiled JARs on our
Jenkins.
Prerequisites
- JDK 8
- Git
Compiling
Run the following commands:
Windows
Code:
git clone https://github.com/CloudburstMC/Nukkit
cd Nukkit
git submodule update --init
./mvnw clean package
Linux
Code:
git clone https://github.com/CloudburstMC/Nukkit
cd Nukkit
git submodule update --init
chmod +x mvnw
./mvnw clean package
The compiled JAR can be found in the target/ directory.
Alternative method
Hello, it's me again. Through this
Generic Linux Install article, you have understood how to use Nukkit on Linux
In the next article, we will install Intellij and how to convert .java file to .class
Ok we will proceed to install it now!!!
First you have to download the Intellij for Linux application
Intellij Download Link:
Download
Then you have to extract the Intellij
There are 2 ways to extract Intellij file:
Method 1: Extract by right-click "Extract Here"
Method 2: Extract using terminal
Command to Extract:
tar -xvzf NameFile.tar.gz
So we have successfully extracted File Intellij. Next we will install Java 11 to run Intellij.
Wait !!! If installing Java 11 how to run Java 8 for Nukkit ?
Rest assured, I will show you how to run Intellij on Java 11 and Nukkit on Java 8 at the same time
Command to install Java 11 for Linux:
Ubuntu, Debian:
sudo apt-get install openjdk-11-jdk
CentOS, Rocky, RedHat:
sudo yum install java-11-openjdk
openSUSE:
sudo zypper install java-11-openjdk-devel
Arch:
sudo pacman -S jdk11-openjdk
Next, You need to set default java 8 for Nukkit
Command to set default java:
sudo update-alternatives --config java
For example my Java 8 is 1 then I will type 1 and Enter to set Java 8 as default java
sudo update-alternatives --config javac
javac does the same thing as above
Alright, next start running Intellij:
To launch Intellij, navigate to the previously extracted Intellij folder. Then click on the "bin" folder and edit the idea.sh file in the "bin" folder as follows:
Add this line in idea.sh:
export JAVA_HOME="/usr/lib/jvm/Your Name Java 11/"
"Your Name Java 11" Is the name of the Java 11 file on your Linux. Here is an example image:
Well, you've finished installing Intellij. So let's start converting the .java file to .class
Command to launch Intellij:
bash idea.sh
To be able to run maven error free. We need to install maven for Linux
Ubuntu, Debian:
sudo apt-get install maven
CentOS, Rocky, RedHat:
sudo yum install maven
openSUSE:
sudo zipper install maven
Arch:
sudo pacman -S maven
Then restart Intellij and relaunch Intellij
Now I will take the example of the Nukkit server file on github
Link Download:
Download
You download this file and unzip the file
We proceed to select the previously unzipped file
Click "Open" in Intellij, then select the file you want to Build
Alright, you'll be in the world of Nukkit java code. You will have to wait for the maven bar to finish loading then we will continue to the next step
After maven finished loading. They will add Java JDK 8 for File Nukkit
Here is an example image for you:
You can choose a place recommended by Intellij below. But I want to choose JDK more carefully.
If you have JDK folder more folder than other JDK file. Then it's the JDK you should choose it. The other JDKs are paths like desktop. So I will choose the folder Java 1.8.0.312.b07
We will wait for the bar below like maven to finish loading. After it finishes loading, we will enter the command to proceed with Build .java to .class
Command to Build File.jar:
mvn clean package
If you wonder what is mvn clean package? I will always explain to you.
"mvn" stands for maven, it will read the pom.xml file to support the Nukkit file.
"clean" is considered to clean the old build file in the directory named "target"
"package" is called create file.class, it will merge all file.classes in "target" directory to generate file.jar when it receives "mvn" command
As simple as you think: build + delete + create new file
After the Build is successful, it will show this text that you have created a file.jar
To get the file.jar, it's in the "target" folder of the folder you chose to Build
Good luck. If you have difficulty. Please get in touch via the Discord Nukkit team.