A simple sample application demonstrating running Swing applications remotely.
We use Gradle. So you can run Gradle tasks as follows:
# example of running `build` task:
./gradlew build
There is OriginalMain
class, which is an example of a custom Swing application. Also, there is HeadlessSupportingMain
class, which demonstrates lines added to run the demo app in the headless mode.
Here are several ways to run this demo app. Using them, you can understand how to run your own app.
Run configuration Gradle task |
Main class | VM option |
---|---|---|
(UI) OriginalMain runUiOriginalMain |
org.jetbrains.projector.demo.OriginalMain |
Blank |
(UI) HeadlessSupportingMain runUiHeadlessSupportingMain |
org.jetbrains.projector.demo.HeadlessSupportingMain |
Blank |
(Headless) HeadlessSupportingMain runHeadlessHeadlessSupportingMain |
org.jetbrains.projector.demo.HeadlessSupportingMain |
-Dorg.jetbrains.projector.server.enable=true |
(Headless) ProjectorLauncher runHeadlessProjectorLauncher |
org.jetbrains.projector.server.ProjectorLauncher |
-Dorg.jetbrains.projector.server.classToLaunch=org.jetbrains.projector.demo.OriginalMain |
To access headlessly run app, you can use Projector web client. It will be available on http://localhost:8887. Or you can use any other way of connection, feel free to check the corresponding documentation page.
There are two run configurations. Jars will be built in the build/libs
dir.
Gradle task: jarHeadlessSupport
.
Its main class is HeadlessSupportingMain
and it contains the projector-server
module. To run headlessly, add a JVM option -Dorg.jetbrains.projector.server.enable=true
.
Gradle task: jarOriginal
.
Its main class is OriginalMain
.
To launch the original version with UI, run:
java \
-classpath projector-demo-original.jar \
org.jetbrains.projector.demo.OriginalMain
To launch the original version headlessly, place the classpath of projector-server
into libs
dir and run:
java \
-classpath projector-demo-original.jar:libs/* \
-Dorg.jetbrains.projector.server.classToLaunch=org.jetbrains.projector.demo.OriginalMain \
org.jetbrains.projector.server.ProjectorLauncher