Your first script
Create a Player script with one exported property and one overridden method: when its node is ready, it prints a greeting that names the language it was written in. Use the example for one of the languages enabled in your project.
Create src/main/kotlin/com/example/game/Player.kt:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
Create src/main/java/com/example/game/Player.java:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
Create src/main/scala/com/example/game/Player.scala:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
This small example already shows the main building blocks:
@Scriptmakes the class available to Godot.- Inheriting
Nodemakes it a Godot script class. @Exportregisters the property and shows it in the Inspector, where you can change the greeting without touching the code.- Overriding
_ready()runs code once the node and its children are ready. GD.print(...)writes to the Godot output.
Build it
Your scripts are compiled by Gradle, and you can start that build from wherever you are working:
-
From Godot. In the editor toolbar, leave the task drop-down on Build and click Run Gradle. This is convenient when you are arranging scenes and only need to pick up a code change.

Godot can also build when you start the game. The Build on Run button next to Run Gradle sets what the play buttons, F5, and F6 do, and each click moves to the next option: never (dimmed hammer and wrench, the default), when a script changed since the last build (hammer and wrench), and always (circular arrow). Shift+click a play button to build first only when a script changed, or Ctrl+click (Cmd+click on macOS) to always build first; both take priority over the button. If that build fails, the game does not start and the Gradle output opens in a window. The button's tooltip shows the current option and these shortcuts.
-
From IntelliJ IDEA. The IDE already manages Gradle for you: run the
buildtask from the Gradle panel, or bind it to a run configuration.
-
From a terminal. Run the wrapper at the project root:
gradlew buildon Windows,./gradlew buildon Linux and macOS.
Note
On Linux or macOS, the build can fail if gradlew is not executable:
1 | |
Run this command from the project root, then build again:
1 | |
Whichever way you build, the editor notices the new jar and reloads your classes automatically. The toolbar's JVM status indicator is red when no JVM library could be loaded, yellow while the JVM starts or waits for code, and green when your classes are loaded.

Attach it to a node
Attach Player.kt, Player.java, or Player.scala exactly like a GDScript: drag it from the FileSystem dock onto the node, or use Attach Script. In the dialog, the Language entries are Kotlin, Java, and Scala; select the language and the source path. Edit the source in IntelliJ IDEA; Godot's script editor opens and highlights JVM sources but offers no code completion or error checking for them.
Build the script JAR
A source file alone is not enough. If you attach it before building, the node warns that the script cannot be found in the JVM project. Its class must be present in the built JAR. Build the JVM project to load the class and its exported properties.
Select the node: the Inspector shows the Language property from the example. See Script files for source-file association rules.
Run it
Run the scene or the project exactly as you would with any Godot game, with the play buttons or F5 and F6. The Output panel shows your greeting. Change the Language value in the Inspector and run again to see the exported property in action.
Godot-JVM keeps an eye on stale builds for you. If you edit a script and forget to rebuild, every node using it shows a configuration warning in the scene tree saying the script has been modified since the last build. Rebuild, and the warning disappears.
Once you see the greeting, you know the whole loop works: write, build, attach, run. The User guide covers everyday scripting with Godot-JVM, building and debugging your project, and exporting your game.