B4J Code Snippet easily compile and run B4J project with javaFx

Hi,

after reading this post, i write this little batch script (compile_and_run_jar.bat)

Batch:
echo off
cls
echo ==========================================
echo compile B4J project and run it with JavaFx
echo ==========================================

rem search for project file and store it in variable project (without extension)
for /f "delims=" %%f in ('dir /B ".\*.b4j"') do set project=%%~nf
echo Project : %project%

rem set variables
set BAJCOMPILER="C:\Program Files (x86)\Anywhere Software\B4J\b4jbuilder.exe"
set JAVADIR="C:\java\jdk-11.0.1"
set JARFILE="%cd%\Objects\%project%.jar"
set STARTDIR="%cd%\Objects\"

rem compile project
%BAJCOMPILER% -task=build

rem check compilation error (exit code 1)
if %ERRORLEVEL% == 1 (
    pause
    exit 1
)

rem run jarfile with Javafx
%JAVADIR%\bin\java.exe --module-path %JAVADIR%\javafx\lib --add-modules=javafx.controls,javafx.fxml,javafx.web -jar %JARFILE%

rem remove Objects folder
rd objects /s/q
exit 0

Put it in the project folder and run it. It will :
- compile the project
- run the jar file with javaFx support
- delete the objects folder when finished

spsp
 

andrewmp

Member
Licensed User
Longtime User
--add-modules=javafx.controls,javafx.fxml,javafx.web

Unfortunately it does not always work jar often contains other modules/libraries. Specific case if you use preferencesdialog and a field with options eg :

{
"options": ["a","b"],
"title": "Test",
"type": "Options",
"key": "id",
"required": true
},
The file list will not open...
 

spsp

Active Member
Licensed User
Longtime User
--add-modules=javafx.controls,javafx.fxml,javafx.web

Unfortunately it does not always work jar often contains other modules/libraries. Specific case if you use preferencesdialog and a field with options eg :

{
"options": ["a","b"],
"title": "Test",
"type": "Options",
"key": "id",
"required": true
},
The file list will not open...

Hi,

I use the batch file with several projects with preferencesdialogs and other libraries without problem.

If you can compile the project with B4J IDE, it should be OK with the batch file.

spsp
 
Top