Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions IDE/VSCode/Modular/Gradle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## Modular samples for Visual Studio Code

JavaFX 17 samples to run from Visual Studio Code with different options and build tools.

Version Visual Studio Code: 1.63.0 or higher.

Download [JDK 11 or later](http://jdk.java.net/) for your operating system. Make sure `JAVA_HOME` is properly set to the JDK installation directory.

### Gradle

For the first time only:

- Make sure you have installed following extensions in your Visual Studio Code:
- [Extension Pack for Java](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-pack)
- [Gradle for Java](https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-gradle)

- Clone the sample, open the folder `hellofx` in Visual Studio Code.

To run the JavaFX application, you can open the `Gradle Projects` explorer, expand `hellofx` > `Tasks` > `application` and run the Gradle task: `run`.

![Run](./run.png)

Or alternatively run from terminal:

On Linux or Mac run:

cd IDE/VSCode/Modular/Gradle/hellofx
./gradlew run

On Windows run:

cd IDE\VSCode\Modular\Gradle\hellofx
.\gradlew.bat run

#### Custom Runtime

To create and run a custom JRE, you can open the `Gradle Projects` explorer, expand `hellofx` > `Tasks` > `build` and run the Gradle task: `jlink`. The executable file will be generated at `build/image/bin/hellofx` (Or `build\image\bin\hellofx.bat` on Windows).

Or alternatively run from terminal:

On Linux or Mac run:

cd IDE/VSCode/Modular/Gradle/hellofx
./gradlew jlink
build/image/bin/hellofx

On Windows run:

cd IDE\VSCode\Modular\Gradle\hellofx
.\gradlew.bat jlink
build\image\bin\hellofx.bat
26 changes: 26 additions & 0 deletions IDE/VSCode/Modular/Gradle/hellofx/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
plugins {
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.10'
id 'org.beryx.jlink' version '2.24.4'
}

repositories {
mavenCentral()
}

javafx {
version = "17.0.1"
modules = [ 'javafx.controls', 'javafx.fxml' ]
}

application {
mainClass = "org.openjfx.MainApp"
mainModule = "hellofx"
}

jlink {
options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
launcher {
name = 'hellofx'
}
}
4 changes: 4 additions & 0 deletions IDE/VSCode/Modular/Gradle/hellofx/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## if JAVA_HOME is not JDK, set and uncomment:
#org.gradle.java.home=/path/to/jdk/


Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
172 changes: 172 additions & 0 deletions IDE/VSCode/Modular/Gradle/hellofx/gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

84 changes: 84 additions & 0 deletions IDE/VSCode/Modular/Gradle/hellofx/gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions IDE/VSCode/Modular/Gradle/hellofx/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = 'hellofx'
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module hellofx {
requires javafx.controls;
requires javafx.fxml;
requires transitive javafx.graphics;

opens org.openjfx to javafx.fxml;
exports org.openjfx;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.openjfx;

import javafx.fxml.FXML;
import javafx.scene.control.Label;

public class FXMLController {

@FXML
private Label label;

public void initialize() {
String javaVersion = System.getProperty("java.version");
String javafxVersion = System.getProperty("javafx.version");
label.setText("Hello, JavaFX " + javafxVersion + "\nRunning on Java " + javaVersion + ".");
}
}
Loading