JavaFX application fail to launch with native exe bundle created with intellij ide - intellij-idea

I have build a JavaFX application which can be executed by its jar file. However if i try to run it using the native exe bundle i am receiving two popups:
Error Invoking method
Failed to launch JVM
and the application fails to start.
The Javafx application is build with intellij ide.
The project structure looks as follows;
when launching the application following popup shows..
The config file looks as follows:-
The packaged jar file is executing properly...
the problem occurs when starting application with launching exe file.
kindly tell me what could went wrong?
UPDATE:
It seems that the build output runtime/bin directory does not contain java.exe file therefore i think the application does not launches.
the output when try to run the application is as follows:
i have build the application with intellij idea, i think there is a problem with that. Kindly look into this matter.
UPDATED:-

Run it from the command line using the runtime that was bundled for you:
If you made an executable Jar (with a proper manifest specifying the classpath and main class)
cd firecap
runtime\bin\java -jar app\libs\your-main.jar
If you don't have an executable jar use something like
cd firecap
runtime\bin\java -cp app\libs\*.* your.main.class.name
Since java.exe is a console program you should be able to see the full error output to get a better idea of what is going wrong.
You very likely have missed including a needed module in the runtime.
It is also possible you ran into a bug that I discovered recently: https://bugs.openjdk.java.net/browse/JDK-8254920
I created my runtime image with this command:
"C:\Program Files\BellSoft\LibericaJDK-15-Full\bin\jlink.exe" --no-header-files --no-man-page, --compress=1 --add-modules java.management,java.logging,javafx.controls,java.xml,java.desktop --output C:\MyProject\build\image\runtime
But yours may be different depending on what modules you need. Note also that I used a JDK from BellSoft that included the JavaFX modules to make it easier.

Related

creating a Minecraft PVP client: error message when running minecraft [duplicate]

What are the possible causes of a "java.lang.Error: Unresolved compilation problem"?
Additional information:
I have seen this after copying a set of updated JAR files from a build on top of the existing JARs and restarting the application. The JARs are built using a Maven build process.
I would expect to see LinkageErrors or ClassNotFound errors if interfaces changed. The above error hints at some lower level problem.
A clean rebuild and redeployment fixed the problem. Could this error indicate a corrupted JAR?
(rewritten 2015-07-28)
Summary: Eclipse had compiled some or all of the classes, and its compiler is more tolerant of errors.
Long explanation:
The default behavior of Eclipse when compiling code with errors in it, is to generate byte code throwing the exception you see, allowing the program to be run. This is possible as Eclipse uses its own built-in compiler, instead of javac from the JDK which Apache Maven uses, and which fails the compilation completely for errors. If you use Eclipse on a Maven project which you are also working with using the command line mvn command, this may happen.
The cure is to fix the errors and recompile, before running again.
The setting is marked with a red box in this screendump:
try to clean the eclipse project
you just try to clean maven by command
mvn clean
and after that following command
mvn eclipse:clean eclipse:eclipse
and rebuild your project....
Your compiled classes may need to be recompiled from the source with the new jars.
Try running "mvn clean" and then rebuild
The major part is correctly answered by Thorbjørn Ravn Andersen.
This answer tries to shed light on the remaining question: how could the class file with errors end up in the jar?
Each build (Maven & javac or Eclipse) signals in its specific way when it hits a compile error, and will refuse to create a Jar file from it (or at least prominently alert you). The most likely cause for silently getting class files with errors into a jar is by concurrent operation of Maven and Eclipse.
If you have Eclipse open while running a mvn build, you should disable Project > Build Automatically until mvn completes.
EDIT:
Let's try to split the riddle into three parts:
(1) What is the meaning of "java.lang.Error: Unresolved compilation
problem"
This has been explained by Thorbjørn Ravn Andersen. There is no doubt that Eclipse found an error at compile time.
(2) How can an eclipse-compiled class file end up in jar file created
by maven (assuming maven is not configured to used ecj for
compilation)?
This could happen either by invoking Maven with no or incomplete cleaning. Or, an automatic Eclipse build could react to changes in the filesystem (done by Maven) and re-compile a class, before Maven proceeds to collect class files into the jar (this is what I meant by "concurrent operation" in my original answer).
(3) How come there is a compile error, but mvn clean succeeds?
Again several possibilities: (a) compilers don't agree whether or not the source code is legal, or (b) Eclipse compiles with broken settings like incomplete classpath, wrong Java compliance etc. Either way a sequence of refresh and clean build in Eclipse should surface the problem.
I had this error when I used a launch configuration that had an invalid classpath. In my case, I had a project that initially used Maven and thus a launch configuration had a Maven classpath element in it. I had later changed the project to use Gradle and removed the Maven classpath from the project's classpath, but the launch configuration still used it. I got this error trying to run it. Cleaning and rebuilding the project did not resolve this error. Instead, edit the launch configuration, remove the project classpath element, then add the project back to the User Entries in the classpath.
I got this error multiple times and struggled to work out. Finally, I removed the run configuration and re-added the default entries. It worked beautifully.
Just try to include package name in eclipse in case if you forgot it
Import all packages before using it, EX: import java.util.Scanner before using Scanner class.
These improvements might work and it will not give Java: Unresolved compilation problem anymore.
Also make sure to check compiler compliance level and selected jdk version is same
As a weird case, I encountered such an exception where the exception message (unresolved compilation bla bla) was hardcoded inside of generated class' itself. Decompiling the class revealed this.
I had the same issue using the visual studio Code. The root cause was backup java file was left in the same directory.
Removed the backup java file
When the build failed, selected the Fix it, it cleaned up the cache and restarted the workSpace.

"NoClassDefFoundError" when the jar file built by Intellij Idea artifacts was executed in command line

I have a problem with running my jar execution file built by Intellij Idea Artifacts in command line. Error message is
NoClassDefFoundError: io.mattmoore.kotlin.playground.cinterop.Greeter
But it worked when I use the IDE to execute "RUN".
Do you have any Idea why is that happening?
Highly appreciated if someone could give me a hint about how to fix it.
Harrison
IDE knows better where to find dependencies, but once you export .jar file, you need to manually ensure that no dependency is missing
(and that all get loaded).
Example:
To run MyProgram.jar, place all your dependencies inside of libs directory (which you need to create beside it), then use command like:
java -cp 'MyProgram.jar:libs/*' my_package.MyMainClass
OR for Windows (use semicolon)
java -cp 'MyProgram.jar;libs/*' my_package.MyMainClass
Note that dependency means other .jar files, for example, the one that defines io.mattmoore.kotlin.playground.cinterop.Greeter class.
See also How to call ".jar” with additional classpath option?

How to run a java application created in intelliJ at the command line?

I have a simple "Hello World" application created in intelliJ using Java. How do I run the application outside of intelliJ at a terminal command line?
First result in google: http://www.skylit.com/javamethods/faqs/javaindos.html
Run Command Prompt (found under All Programs/Accessories in the Start menu). Type
C:\> cd \mywork
This makes C:\mywork the current directory.
C:\mywork> dir
This displays the directory contents. You should see HelloWorld.java among the files.
C:\mywork> set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin
This tells the system where to find JDK programs.
C:\mywork> javac HelloWorld.java
This runs javac.exe, the compiler. You should see nothing but the next system prompt...
C:\mywork> dir
javac has created the HelloWorld.class file. You should see HelloWorld.java and HelloWorld.class among the files.
C:\mywork> java HelloWorld
This runs the Java interpreter. You should see the program output:
Hello, World!
I have been struggling to output java code to terminal these days. I finally found a way to do that. Following are my steps hope this is of some use to you.
Get the class path where your main method locates and switch to that directory. In my case, my main stays in
Set path of your jdk, for example
set path=C:\Program Files\Java\jdk1.8.0_66\bin
Compile and run your code. Remember to include your package name. About package please have a look of this site: http://www.javatpoint.com/package
In my case, my main method is in Main.java, and Main.java is included in package sample
You can do exactly the same steps to get your output from cmd, command line console.

Getting error Could not find or load main class org.testng.TestNG

I'm trying to run TestNG from command line, but it's giving me error.
Can someone tell me where am I going wrong?
java -cp C:/TestNG directory/testng-6.2.jar;C:\project directory\src\com\suites\suite\shop org.testng.TestNG testng.xml
Error: Could not find or load main class org.testng.TestNG
My scripts runs fine when I ran them from eclipse testng plugin.
Copy the below commands in a text file.
Edit the location.
Save it as yourtext.bat
Now, double click on the batch file created.
cd C:\Workspace\projectname
java -cp C:\Workspace\projectname\lib*;C:\Workspace\projectname\bin org.testng.TestNG testng.xml
Path of TestNG.jar file was not set up.
Follow instructions of following site to set up. It worked for me:
http://qtp-automate.blogspot.com/2011/10/running-selenium-testng-test-from.html
Try above answers.
If still not work, then you might have downloaded the wrong version of testng.jar. From link testng.org, please click "here for ant users" to download a full testng.jar(11 mega bytes), not a "Maven Central" version(no more than 100k).
I have tested those two versions on centos following testng tutorial point
Possibly your testng.jar file is not in the lib folder that C:\Workspace\projectname\lib.
You should find testng.jar first in your computer and move it manually to C:\Workspace\projectname\lib. Then it will work
Check that the lib folder contains testng-6.8.jar(or any other version) file because testng.xml even executes successfully without testng-6.8.jar (or any other version) with the jars that gets added when we add TestNG library.
My Assumptions:
You are trying to run test file from command prompt
libs folder generated under Project/tagret upon using "mvn clean package -DskipTests"
class file generated under Project/target/test-classes/package-name
With above assumptions in mind, you can follow below process.
Setting class path in command prompt:
1. Open project location in command prompt
2. set classpath=C:\User\SeleniumTestProject\target\test-classes;C:\User\SeleniumTestProject\target\libs\*
3. java org.testng.TestNG C:\User\SeleniumTestProject\testng.xml

On UnsatisfiedLinkError, clarification needed

When building the project from command line using mvn clean install everything builds without any issues.
When running some tests that use precompiled C libraries from IntelliJ, tests fail with java.lang.UnsatisfiedLinkError
I may be completely off here, but does IntelliJ not see the .so file? Is so, how can it be added please?
Shared library fails to load with UnsatisfiedLinkError if:
it's not in the working directory configured in the test run configuration.
it's not in PATH environment (on Mac Terminal and GUI apps have different environment, see this answer). Run IDEA from the Terminal open -a /Applications/IntelliJ\ IDEA\ 12.app/ to make environment the same.
it's not in the location specified using -Djava.library.path VM option.
.so depends on some other library that is not found for any of the 1-3 reasons (or the dependency of that dependency is not found, etc).