B4J Question Cross-platform development

Discussion in 'B4J Questions' started by shhammer5634, Jul 18, 2019.

  1. shhammer5634

    shhammer5634 Member Licensed User

    I'm in the process of developing a B4J console application that is targeted for a Linux OS (an Ubuntu Digital Ocean droplet). The development is being done on a Windows box that is old enough to still have the Java SDK loaded and not OpenJDK. Even though the console application doesn't have any graphical UI, it still needs JFX. It generates some Excel spreadsheets and needs to set color for them. When I compile the application and move it to the droplet and try to run it, I get this error:

    root@Ubuntuvpn:/usr/ePAL# java -jar ConsoleTest.jar
    main._process_globals (java line: 3089)
    java.lang.NoClassDefFoundError: javafx/stage/Window
    at b4j.example.main._process_globals(main.java:3089)
    at b4j.example.main.initializeProcessGlobals(main.java:3079)
    at b4j.example.main.main(main.java:27)
    Caused by: java.lang.ClassNotFoundException: javafx.stage.Window
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 3 more

    root@Ubuntuvpn:/usr/ePAL# java -version
    openjdk version "11.0.3" 2019-04-16
    OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu218.04.1)
    OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu218.04.1, mixed mode, sharing)

    I assume the issue is JFX in the OpenJDK environment.

    My question: Is there a way to accomplish setting color without having JFX loaded (example)
    DataRow.GetCell(0).CellStyle.ForegroundColor = fx.Colors.Cyan
    I'm sure I'm being dense. All comments appreciated.
  2. Enrique Gonzalez R

    Enrique Gonzalez R Well-Known Member Licensed User

    There is an error on your project, console aplications doesnt come with JavaFx preloaded or loaded, when you create a new project the IDE ask you if you want it to be with UI or NON UI, if you tell NON UI then no JFX.

    Now you have to see how else change the foreground color (may be with HEX) to avoid using JFX
    Mashiane likes this.
  3. shhammer5634

    shhammer5634 Member Licensed User

    Thanks Enrique, yes that's true. I added JFX to the non-hi project to handle the colors. This project was originally a ui project and I copied code into the new non-hi project. I was just hoping someone could point me in the right direction for setting colors without JFX.

    Appreciate your response.
  4. shhammer5634

    shhammer5634 Member Licensed User

    I guess I should clarify a little more:

    The non-ui console application runs fine on my windows platform with JFX defined and assigns colors etc. It's when it runs on the linux system that has OpenJDK11 installed that I run into trouble.

    I made a simple little UI application so I could find out the values of the colors I needed by logging them. But when I try to assign one of those values in this line:
    DataRow.GetCell(0).CellStyle.ForegroundColor = 0x00ffffff
    I get this error:
    Types do not match. (Warning #22)

    I have tried to assign the value to a variable:
    Dim Cyan as Int = 0x00ffffff
    But the first line gives me the same error.

    How do I assign a color value to a POI element like the one shown in the first code line without using JFX?

  5. Enrique Gonzalez R

    Enrique Gonzalez R Well-Known Member Licensed User

    okey know i see that foregroundcolors was hardwired to JFX paint, i think you can change it with javaobject. i will try to come up with something
  6. shhammer5634

    shhammer5634 Member Licensed User

    Thanks Enrique.

    I found a post on the forum that helped once I know what to ask for. This is a modified version of that code:

    Public Sub PaintToAwtColor(A As Int, R As Int, G As Int, B As Int) As Object
    Dim JO As JavaObject
    Return JO
    End Sub
    But now I'm running into other issues. It seems some of the libraries I'm using require JFX too. I'll have to go back to the drawing board.

    Appreciate the help.
  7. Erel

    Erel Administrator Staff Member Licensed User

    Why are you using Swing? Why not create a regular UI app?
  8. shhammer5634

    shhammer5634 Member Licensed User

    Hi Erel,

    Because this will be running in a non-ui environment. All interactions with this application will be done through a remote client. The system this will be installed on is linux with no gui installed. Should I be using the regular UI and simply not define or display a form?

  9. DonManfred

    DonManfred Expert Licensed User

    use a nonui app then. The client can communicate with the server using okhttputils2.
  10. OliverA

    OliverA Expert Licensed User

    I'm guessing here that @shhammer5634 is using jPoi and he would like to do the spreadsheet manipulation in a non-ui application. Setting the color of a cell requires "Colors" which seems to be a JavaFX class. He's inquiring (at least that is what I get from reading the posts) if there is another way to set the colors without using that JavaFX class so JavaFX is not required for the non-ui app or if there is a way to include JavaFX in the non-ui app without issues (and how to do that).
  11. shhammer5634

    shhammer5634 Member Licensed User

    Correct sir. I've been able to get around that for now though.
  12. shhammer5634

    shhammer5634 Member Licensed User

    Thank for the confirmation.
  13. William Lancee

    William Lancee Member Licensed User

    In working with jPoi, I use the UI version and don't show the MainForm. It looks and feels like a console app, but all Fx methods are available.
    Erel likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice