2

I want to develop basic javaFX applications using Gitpod. I have tried many different configurations but nothing works. The is one example repo on github https://gitpod.io/#https://github.com/RohitAwate/Everest This example is far to complex. I just want a basic app with a few buttons and text boxes.

D C
  • 31
  • 4
  • 1
    You should do some research before asking these sort of questions. Or at least show something you have tried and/or errors you have received. – natral Nov 13 '19 at 23:15
  • 1
    Noted. I'm pretty new to this. In the future, I will be a good man and thorough! – D C Nov 15 '19 at 10:55

2 Answers2

3

To start with JavaFX you should search for a Hello World example on GitHub. For example try this that I found with a Google search: https://github.com/callicoder/javafx-examples/

  1. Open the repository in Gitpod: https://gitpod.io/#https://github.com/callicoder/javafx-examples/
  2. In the Terminal type: gp init
  3. Gitpod opens two new editors: One to edit .gitpod.yml and one to edit .gitpod.Dockerfile. I added examples below based on Everest.
  4. Fork this repository and commit+push the changes.
  5. Open your fork in Gitpod.
  6. A notification appears that a port 6080 has been opened. Click on "Open Browser". A new browser tab opens with VNC.
  7. Run cd javafx-hello-world/src && javac HelloWorldApplication.java && java HelloWorldApplication in the Terminal in Gitpod.
  8. Change to the VNC browser tab. A sample window with the Hello World message has been opened.

Sample .gitpod.yml:

image:
  file: .gitpod.Dockerfile

ports:
- port: 6080

Sample .gitpod.Dockerfile:

FROM gitpod/workspace-full-vnc

RUN apt-get update \
    && apt-get install -y openjfx libopenjfx-java matchbox \
    && apt-get clean && rm -rf /var/cache/apt/* && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/*
Cornelius
  • 400
  • 3
  • 12
  • This is still not displaying the GUI for me. I have updated the command in step 7. `cd javafx-hello-world/src/ && javac HelloWorldApplication.java && java HelloWorldApplication` It compiles but I get an error on running:Exception in thread "main" java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.refle – D C Nov 14 '19 at 13:06
  • Did the notification of step 6 appear and have you been able to open the noVNC tab in a new browser (before step 7)? – Cornelius Nov 14 '19 at 13:17
  • Here is my running fork: https://gitpod.io/#https://github.com/corneliusludmann/javafx-examples – Cornelius Nov 14 '19 at 13:18
  • I am not sure if this requires a new question but there are two issues with the JavaFX GUI display on Gitpod I would like to fix. 1. The JavaFX stage does not appear. I expect this https://docs.oracle.com/javafx/2/get_started/img/helloworld.png But I am missing the blue outer rim of the GUI with the minimise and X button. I think this has something to do with the matchbox window manager software we have in the Dockerfile. I changed this to Openbox and I still had the same issue. 2. The JavaFX GUI is centred in the browser window. How can I make it appear in the top left corner? – D C Nov 15 '19 at 11:08
  • As you mentioned, the 'window manager' is responsible for this. You'll find the configuration of the windows manager for the VNC workspace of Gitpod there: https://github.com/gitpod-io/workspace-images/tree/master/full-vnc. Based on this, you can install your own window manager that fulfills your needs. However, that is independent of Gitpod and something that I can't help you with at the moment. If you know what window manager you want to use and how you want to configure it but still has problems to run this in Gitpod I'll be happy to help you with this. – Cornelius Nov 16 '19 at 12:28
  • The commands in the dockerfile must be run as `sudo`. Perhaps gitpod changed the permissions of the default user? (I would edit the answer, but the edit queue is full.) – gillesB Sep 15 '22 at 13:27
2

You can find the configuration for the Everest project here

https://github.com/gitpod-io/definitely-gp/tree/master/Everest

Just copy the two files into the root of your simple example, commit and start a fresh workspace.

Sven Efftinge
  • 3,065
  • 17
  • 17