Export eclipse scout project from command line - eclipse-scout

Currently I use the "Export a Scout Project" wizard to deploy an application to tomcat8.
Is it possible to export an eclipse scout project from the command line?

This depends on your Scout version: 5.1 and newer use a plain maven build which generates a war file. This can be invoked from command line using mvn install on the parent pom of your project. See http://tools.bsi-software.com/scoutbook/5.2/latest/book_scout_intro/scout_intro/scout_intro.html#sec-helloworld_export for more details. Please note that this version is not released officially yet and will be part of the Eclipse Neon release in 2016-06-22.
Versions before 5.1 are based on the PDE product export mechanism. This exports a *.product file as if you click on the "Eclipse Product export wizard" link in the product editor. This can also be executed from command line using a headless eclipse: http://help.eclipse.org/juno/topic/org.eclipse.pde.doc.user/tasks/pde_product_build.htm?cp=4_2_0_0.
However you may need to post process the exported war files manually and add artifacts like the equinox servlet bridge, web.xml and launch.ini files.
Alternatively you can also setup a maven+tycho build as already mentioned by Jmini.

Related

java.lang.module.FindException: Module test not foundIntellidea

I am have this Exception please help me!
"Error occurred during initialization of boot layer
java.lang.module.Find Exception: Module test not found"
But i write VM option "--module-path "D:\UT java\javafx-sdk-17.0.1\lib" --add-modules javafx.controls,javafx.fxml"
and i have module-info.java "
requires javafx.fxml;
requires javafx.controls;
requires javafx.graphics;
requires java.sql;
requires java.desktop;
requires jdk.jfr;"
i add my sdk. And if i create javafx demo project and execute him it work. and if i start change fxml file and change controller i have this exception.
I have IntellIJIdea 2021, javafx-sdk-17.0.1, jdbc jr 8,11,16
Steps to fix:
Delete the JavaFX sdk (you don’t need it).
Delete old Java versions (they are obsolete).
Update your IntelliJ IDE and IDE plugins to the most recent release, 2021.3.2+.
Create a new JavaFX project using JDK and JavaFX 17.0.2+.
Select Maven for the build system unless you know and prefer Gradle.
Do not set VM arguments, you don’t need them.
Adding modules via the --add-modules VM arguments is unnecessary when you have a valid module-info.java file.
The --module-path is still required so that the modules can be found, but Idea will provide the correct path for your modules automatically when it recognizes the modules through your Maven dependencies.
So you don't need to explicitly define the --module-path VM argument yourself for a Maven based build (that would be difficult to do anyway because the modules are all downloaded to different directories in your local maven repository).
Test it works following the Idea create new JavaFX project execution instructions.
Add additional modules one at a time by adding their maven dependency to pom.xml and the requires clause to module-info.java.
Ensure you synchronize the Maven and Idea projects between each
addition.
See, for example, this question on correctly adding the javafx.media module.
Adding other modules such as javafx.web, javafx.fxml or javafx.swing follows a similar pattern.
Test between each addition by building and running the project, to ensure you haven’t broken anything.
Copy your original source code into the appropriate package directories under the new project source directory:
src/main/java
Place resources in:
src/main/resources
following the Eden resource location guide.
Fix any errors, ensure everything compiles and runs, then test it.

Error: JavaFX runtime components are missing, (Permanent Solution)

I know you can solve this by adding
--module-path "pathToLib" --add-modules javafx.controls,javafx.fxml,javafx.graphics when running the jar file in command line.
But my question is, Is there no permanent solution to solve this error in system settings or configurations and be able to run a jar file as normal as java -jar myfile.jar rather than every time I am suppose to add the module java --module-path "C:\Users\..\Downloads\javafx-sdk-17.0.2\lib" --add-modules javafx.controls,javafx.fxml,javafx.graphics -jar myfile.jar
Also I know you can make a script for this operation for every jar file, but I was thinking of something like system settings or configuration that will be applicable for all jar file with javafx, and be able to run the jar file as normal as java -jar myFile.jar
I am using Ant as a build tool.
Recommended Alternatives
See the packaging resources of the JavaFX tag for recommended alternate solutions to a jar distribution: jlink, jpackage, or native image.
Using JRE's that include JavaFX
Pre-installed JREs that include JavaFX, such as some Bellsoft, Zulu, and Corretto distributions, will execute JavaFX apps without additional module specifiers because they include the JavaFX modules in the base module setup for their distributions.
Note, you must use the correct versions of the JDKs if you want a JDK which includes JavaFX (not all JDKs include JavaFX):
for BellSoft, download and install the "Full JDK", not the "Standard JDK".
for Zulu, download and install the package type "JDK FX", not "JDK".
You can also create your own JRE distribution that includes JavaFX modules using jlink (which is actually simpler to do than it may sound).
Using ant to build a single JAR containing App and JavaFX components
But I still hope that there might be a solution for the above while working with ANT as building tool for JavaFX.
There is some info on building modular JavaFX apps with ant in this answer:
bad name in value for --add-modules when trying to compile through ant
It probably isn’t everything you are looking for though.
To create a single executable jar using ant, you could try emulating the output of this maven JavaFX shade on classpath answer:
Maven Shade JavaFX runtime components are missing
But use ant tasks to build the massive shaded jar instead of maven. I don’t have explicit instructions for that, you would need to work out to accomplish that non-trivial task yourself.
The created jar will include a launcher class, your application code, dependent library code, JavaFX java, and native code. The jar will run on any modern JRE as long as you have included the native code for the relevant platform. The jar will run in the unsupported classpath configuration.
Zip Distributions
Or (better) create a zip distribution:
only put your own code in your app jar.
place the dependent libraries and JavaFX modules in a lib directory.
Create a script that invokes Java with your jar file running with the modules in the lib directory added.
Make your app modular if possible:
Define a module-info.java.
This step isn’t strictly necessary or reasonably possible for some apps.
Use ant to place everything in a zip file for distribution.
Include a jlink generated JRE in the zip if you want.
Note: the maven JavaFX plugin, once properly configured, can accomplish most of these tasks with a single command:
mvn javafx:jlink
Additional info
See the eden guide for resolving JavaFX runtime components.
Add a module-info.java file under your java/ folder and populate it with the following content:
module module_name {
requires javafx.controls;
requires javafx.fxml;
requires javafx.graphics;
requires java.base;
requires java.desktop;
opens com.example.matformater to javafx.graphics;
opens com.example.matformater.controller to javafx.fxml;}

how to create a distributable .jar with intelliJ JavaFX

It's been a few days since I've been trying to export a very simple project made in JavaFX but I have a very frustrating problem: To run the jar I need to open cmd navigate to the jdk folder and execute the following code java --module-path %path_to_JavaFX_on_my_pc% --add modules=javafx.controls,javafx.fxml,javafx.graphics -jar %path_to_jar% where I point to the jfx folder on the pc and add the necessary modules to run the jar.
run the jar using java java -jar %path_to_jar% results in the following error: Error: JavaFX runtime components are missing, and are required to run this application
The project is modular, having declared module-info.java with the following code:
module Timer {
requires java.prefs;
requires com.jfoenix;
requires javafx.base;
requires javafx.controls;
requires javafx.fxml;
requires javafx.graphics;
requires javafx.media;
requires javafx.web;
requires javafx.swing;
opens main;
exports main;
}
when exporting the artifact I include all the .jar contained in the javafx, so why should I point to it externally?
The app runs well when I run it through the IDE, I didn't even have to add VM options.
My goal is to create an application that can actually be distributed, without the user needing to have any knowledge beyond the basics to run it, no jre, jdk, jfx, cmd code, etc... just click twice and done.
The question is: How do I generate an executable file that can be opened with 2 clicks like any other application on the pc on *any pc?
finally I got a solution to my problem.
1 ° - It was necessary to solve the problem when generating a java artifact using javaFx in intelliJ: In JDK 13 the IDE threw the following error
Can't build artifact - fx: deploy is not available in this JDK
the easiest solution for that was to return on JDK 9 ond the javaFx was still built in and everything worked fine. Having done that, I was able to generate .jar artifacts that worked without the need to use command line tools.
2 ° -So I needed to generate a native executable for my application: In this topic there is an excellent list of tools that create launchers for java artifacts (Ideal was to convert but there gets a little complicated). What worked best for me was Jsmooth where I was able to set up a launcher that built in my .jar and where I could also attach a copy of the JRE for distribution on computers without Java
It is worth noting that I develop desktop applications just for my use and that of some friends, they do not work with sensitive data and do not require a high level of security and therefore there is no problem using an old version of jdk, in any other case, no recommend this approach.
Thank you all for your help.
I ran into the same problem with JavaFX 11. The way I did it, to be able to generate the jar artifact, I set the Project Settings - Artifacts - Type to JAR rather than JavaFX Application. That enabled me to create a jar in the out directory of my project. Afterwards, I wrote a batch file that created a custom jre for my app (as small as ~40 MB for a small app), including JavaFX. I called that bat file create.bat and placed that bat file in the same folder as my jar artifact.
Now, provided
my jar artifact is called app.jar,
path to JDK is D:\jdks\jdk11,
path to JFX mods is D:\jdks\jfx11\jmods,
module name is com.epsilon, and
path to Main class is com.epsilon.Main,
below is the contents of the bat file to create a custom JRE, including JavaFX. It created a custom JRE in the folder dist, the launch file is in the dist\bin directory called run.bat.
rem This sets the variable DIR to the current directory with the jar artifact
set DIR=%~dp0
rem This creates a temporary mod file
D:\jdks\jdk11\bin\jmod create --class-path %DIR%app.jar %DIR%temp.mod
rem This creates distributable JRE
D:\jdks\jdk11\bin\jlink ^
--compress=2 ^
--strip-debug ^
--no-man-pages ^
--launcher run=com.epsilon/com.epsilon.Main ^
--module-path D:\jdks\jdk11\jmods;D:\jdks\jfx11\jmods;%DIR% ^
--add-modules com.epsilon ^
--output %DIR%dist
rem This command deletes the temporary mod file
del %DIR%temp.mod
rem You can create a shortcut to your app above the "dist" folder and enter the below line to the shortcut's target property
rem %windir%\system32\cmd.exe /c start "" "%CD%\dist\bin\javaw.exe" -m com.epsilon/com.epsilon.Main
So, this has enabled me to create a working distributable without downgrading Java.

MSBuild not compiling with both /p:Configuration=Release and -p:Configuration=Debug

We are attempting to install a clean build of the newest version of Kentico (12) on Azure, using Kudu, in DEBUG configuration. We traditionally accomplish this by setting SCM_BUILD_ARGS to -p:Configuration=Debug, and all is well. But for some reason in this newer version, the project fails to compile, and I see that this is the command being run:
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "C:\Users\User\Documents\GitHub\Project\CMS\CMSApp.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="C:\local\Temp\8d6d315018f5ff9";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false /p:SolutionDir="C:\Users\User\Documents\GitHub\Project\.\\" -p:Configuration=Debug
Notice both Configuration=Release and Configuration=Debug. The compilation errors are things like Invalid expression term 'string' on the following line of code:
bool licenseOK = LicenseHelper.CheckLicenseLimitations(FeatureEnum.Ecommerce, out int skuCount, out int maxSKUCount);
This doesn't highlight at all in Visual Studio in Debug or Release mode. I am also able to reproduce locally (as shown in my paths above), and if I change the two configurations to both be the same (regardless of whether I choose Debug or Release), it compiles just fine.
What I know I can do is create my own custom deployment command script file as a work-around, but I guess I don't understand why the above MSBUILD command isn't working in the first place.
Any ideas as to why this would work great for all of my ASP.NET projects prior to this one? One thing I know is that Kentico recently included the Roslyn compiler, which I am unfortunately not that familiar with - could that be part of the issue?
UPDATE #1: It appears all of the compilation errors have to do with code that is only valid in C# 7.0. That could be a clue.
It all came down to the fact that the newer versions of Kentico had code that was only valid in C# 7, and required MSBuild 15 to compile. Here's how I was able to set up Kudu:
Add a file named .deployment in the root of my repo, containing only the contents below. This tells Kudu to use a custom deployment script.
Download the deploy.cmd file from my Azure App Service via FTP to the root of my repo, and update it per https://github.com/projectkudu/kudu/issues/2350#issuecomment-373817740 to use the MSBuild 15 path. Details below.
.deployment file contents
[config]
command = deploy.cmd
deploy.cmd updates
1 - Add -MSBuildPath "%MSBUILD_15_DIR%" to nuget call. Example:
nuget.exe restore "{your .sln file path}" -MSBuildPath "%MSBUILD_15_DIR%"
2 - Replace %MSBUILD_PATH% with %MSBUILD_15_DIR%\MSBuild.exe in both occurrences under step 2. Build to the temporary path
This was all that was needed in order to get the build to complete.
As Keith mentions, it was a compatibility issue with C# 7.0 that Kentico 12 uses. This SO thread mentions that you need to run MSBuild version 15 for C# 7.0 code. I ran a similar debug command for my local Kentico 12 project using MSBuild 15, and it succeeded.

How to build into Desktop Java?

So I know you can use ant and mvn to test the project, but I was wondering if there was a way to deploy the project directly as a executable jar or otherwise compile it into a format that can be directly ran? Thanks!
if you are serious about making a launchable desktop program (and especially if its going to be a game), you should use launch4j to make an exe file that launches the jar. It isn't hard to use, and it makes the program much more end user friendly
If your project was generated from the 1.7.2 PlayN archetype or newer, that functionality is already built in. Simply invoke:
mvn package
and a dependencies-included jar file will be generated in:
yourgame/java/target/yourgame-java-1.0-SNAPSHOT-jar-with-dependencies.jar
you can test it by running it standalone like so:
java -jar yourgame/java/target/yourgame-java-1.0-SNAPSHOT-jar-with-dependencies.jar
If your game was generated via an older PlayN archetype, the you can add the necessary bits to your java/pom.xml file by pasting in this in (merging with any existing <build> <plugins> blob):
maven-assembly-plugin
2.4
jar-with-dependencies
${mainClass}
make-assembly
package
single
Then just run mvn package as above to generate the file. Note that you will need to be building against PlayN 1.7.2 or newer as that version is the first one that supported automatic unpacking of the LWJGL native libraries needed to run on the desktop.

Resources