#Compiling Java Code [B42 Version]

1 messages · Page 1 of 1 (latest)

visual aurora
#

Wiki section on the subject: https://pzwiki.net/wiki/Java

As of B42.13 Project Zomboid uses Java Version 25 to run. To compile and run custom code for Project Zomboid: You must be using Java Version 25. Java Version 25 can be found here: (https://www.oracle.com/java/technologies/javase/jdk25-archive-downloads.html)

To compile a .java file into a .class file: You can type this command into a suitable terminal (PowerShell or preferably Command Prompt [CMD] )

⁨```
javac -cp "GameFiles\projectzomboid.jar" "path/file.java"


While making sure to replace "GameFiles" with the path to your Project Zomboid Game Files and "path/file.java" with the path to the file you want to compile

Run the command and your new .class file should be there

If there is no errors in the terminal window but your class file doesn't appear, try refreshing your explorer window


You can then drag the class file into your Game/Server files (GameFiles/zombie/iso for example) and the class files should run


If you are stuck: Don't be afraid to ask for help
hexed badge
visual aurora
rain grotto
#

@hexed badge @visual aurora Does the compiled class need to follow the exact same folder structure as the original Java package? For example, if it's zombie.network.packets.service.GlobalModDataPacket, do I need to create the folders network/packets/service and place the .class file there inside GameFiles/zombie/, just like the original structure?

rain grotto
#

thank you both of you, love you @hexed badge @visual aurora

hexed badge
#

Np

rain grotto
# hexed badge Np

do I need to make zombie folder in ubuntu server? because in serverfiles\java there is no zombie folder

rain grotto
# visual aurora Yes

next question, i think the overide didn't work. Do I need edit these? {
"mainClass": "zombie/network/GameServer",
"classpath": [
"java/.",
"java/projectzomboid.jar"
],
"vmArgs": [
"-Djava.awt.headless=true",
"-Xms16g",
"-Xmx20g",
"-Dzomboid.steam=1",
"-Dzomboid.znetlog=1",
"-Djava.library.path=linux64/:natives/",
"-Djava.security.egd=file:/dev/urandom",
"-XX:+UseZGC",
"-XX:-OmitStackTraceInFastThrow"
]
}

visual aurora
rain grotto
visual aurora
#

It is generally not recommended to force players to manually install something on their computers

#

If you can make it work server sided, do it that way

rain grotto
#

yeah I want to make sure that i can make it work server sided

#

do i need put GlobalModDataPacket.java aswell into the server side?

#

or just the class?