Build for JavaFX project not creating exe - java

I am trying to build a exe file for my JavaFx project. The project is wrote in Java 6 and i have downloaded the standalone JavaFX for Java 6.
When i try to build the build.xml file using ant it is successful but does not create the exe I think it could be because of this message before it completes the build.
Skip [Exe Bundler (based on Inno Setup)] due to [Java Runtime does not
include lib\jfxrt.jar]
How do I go about fixing this?
EDIT:
Fixed How to change JAVA.HOME for Eclipse/ANT

A better solution might be to use the build.xml to output a jar file. Then create a text file then rename it to .bat file that executes the jar. It is pretty straight forward, and if you want to be fancy make an installer that creates shortcuts to the bat file. The contents of the bat file should be as follows (the sample will remove the console from showing up, but if you want the console use java instead of javaw):
#echo off
rem ***** Memory Initialization args *****
SET MYPROPS=%MYPROPS% -Xms512m
SET MYPROPS=%MYPROPS% -Xmx1024m
#echo on
START javaw %MYPROPS% -jar <project_jar>.jar com.example.Main
#echo off

Related

How do I make a code that will make Java code/file to an .exe file [duplicate]

I want to convert a .jar to an .exe for microsoft. Is there any program converter for this?
Also if there's one for Mac and Linux I would appreciate suggestions for those too.
Launch4j works on both Windows and Linux/Mac. But if you're running Linux/Mac, there is a way to embed your jar into a shell script that performs the autolaunch for you, so you have only one runnable file:
exestub.sh:
#!/bin/sh
MYSELF=`which "$0" 2>/dev/null`
[ $? -gt 0 -a -f "$0" ] && MYSELF="./$0"
JAVA_OPT=""
PROG_OPT=""
# Parse options to determine which ones are for Java and which ones are for the Program
while [ $# -gt 0 ] ; do
case $1 in
-Xm*) JAVA_OPT="$JAVA_OPT $1" ;;
-D*) JAVA_OPT="$JAVA_OPT $1" ;;
*) PROG_OPT="$PROG_OPT $1" ;;
esac
shift
done
exec java $JAVA_OPT -jar $MYSELF $PROG_OPT
Then you create your runnable file from your jar:
$ cat exestub.sh myrunnablejar.jar > myrunnable
$ chmod +x myrunnable
It works the same way launch4j works: because a jar has a zip format, which header is located at the end of the file. You can have any header you want (either binary executable or, like here, shell script) and run java -jar <myexe>, as <myexe> is a valid zip/jar file.
JSmooth .exe wrapper
JSmooth is a Java Executable Wrapper. It creates native Windows launchers (standard .exe) for your Java applications. It makes java deployment much smoother and user-friendly, as it is able to find any installed Java VM by itself. When no VM is available, the wrapper can automatically download and install a suitable JVM, or simply display a message or redirect the user to a website.
JSmooth provides a variety of wrappers for your java application, each of them having their own behavior: Choose your flavor!
Download: http://jsmooth.sourceforge.net/
JarToExe 1.8
Jar2Exe is a tool to convert jar files into exe files.
Following are the main features as describe on their website:
Can generate “Console”, “Windows GUI”, “Windows Service” three types of .exe files.
Generated .exe files can add program icons and version information.
Generated .exe files can encrypt and protect java programs, no temporary files will be generated when the program runs.
Generated .exe files provide system tray icon support.
Generated .exe files provide record system event log support.
Generated windows service .exe files are able to install/uninstall itself, and support service pause/continue.
New release of x64 version, can create 64 bits executives. (May 18,
2008)
Both wizard mode and command line mode supported. (May 18, 2008)
Download: http://www.brothersoft.com/jartoexe-75019.html
Executor
Package your Java application as a jar, and Executor will turn the jar into a Windows .exe file, indistinguishable from a native application. Simply double-clicking the .exe file will invoke the Java Runtime Environment and launch your application.
If your program is "publicly available non-commercial in nature" and has "a publicly available Web site that meets the basic quality standards", then you can try and get a free license of Excelsior. If its not then it's expensive, but still a viable option.
Program: https://www.excelsiorjet.com
As a side note: Here's a study of all existing Jar to EXE programs, which is a bit depressing - https://www.excelsior-usa.com/articles/java-to-exe.html
Despite this being against the general SO policy on these matters, this seems to be what the OP genuinely wants:
http://www.google.com/search?btnG=1&pws=0&q=java+executable+wrapper
If you'd like, you could also try creating the appropriate batch or script file containing the single line:
java -jar MyJar.jar
Or in many cases on windows just double clicking the executable jar.
I used Launch4J and it works flawlessy,
First, Go to your jdk and copy the bin and lib folder
Then create a folder for your app and make a folder called jre-(version),
Then paste these inside
Then open launch4j Put the exe file's path (Inside the app's folder)
Then go the jre option and inside bundled paths type jre-(version)
Then in minimun version type the version of the java you coded it in.
Then in the jre option put "Only use private jdk runtimes"
Then hit the gear icon. It will open a file chooser.
Choose your application's folder, done
Now open the exe file generated. It should work.
In case it does not, try the test run button (The green play one). If it says LinkageError in the console below, then in the jvm-options type --enable-preview. It should work.
I hope it helped.
For Windows, you can convert jar to exe using following ways:
Using Netbeans
https://erainnovator.com/convert-jar-to-exe-file/
Using Excelsior JET
https://youtu.be/iQSfUb8chjg
if you need to convert from .jar to .exe from java 14 you can used jpackage
jpackage is a command-line tool to create native installers and
packages for Java applications.
this article will help you

Convert java (with params) to exe

Using Eclipse I've created a Java project with one single class that needs an argument.
In my PC where I have Java installed, I run this:
java -jar test.jar %arg1%
I can put this in a batch file and it runs successfully. The batch has the next lines:
echo off
set /p arg1=Enter path where file is:
java -jar test.jar %arg1%
pause
How can I generate this but in an exe file?
I need that the exe file ask for a path and execute the jar even thought the PC doesn't have Java
P.D. In some forums it's suggests to use launch4j but it doesn't allow dinamical params.

How to determine which command Netbeans is executing to run the project?

I'm developing an Java application using Netbeans and Maven. I'm struggling a lot to run the project as standalone application. Launching the project from Netbeans is all fine but running the executable jar yields an error (failing to load a data file).
I need to know exactly which command(s) Netbeans is executing to run the application. However, the output window of Netbeans only shows me what the application writes "back". Is there a way to figure out/display the command(s) that Netbeans is using to run the project?
Thanks
EDIT: Running the java application and loading files is not the issue here. I'm able to run the application and the libraries are loading correctly. The issue here is to understand how Netbans runs the application (by looking at the commands that are executed).
Netbeans outputs the command it invokes as the very first line of the output.
I use Netbeans 8.2 and that's how it looks like when I hit big green Run button in maven project:
The first line reads (formatted for better readablility):
cd D:\test;
"JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_112"
"M2_HOME=C:\\Program Files\\apache-maven-3.3.3"
cmd /c "\"\"C:\\Program Files\\apache-maven-3.3.3\\bin\\mvn.cmd\"
-Dexec.args=\"-classpath %classpath com.test.AppStarter\"
-Dexec.executable=\"C:\\Program Files\\Java\\jdk1.8.0_112\\bin\\java.exe\"
-Dexec.workingdir=D:\\test\\target\\dist
-Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans 8.2\\java\\maven-nblib\\netbeans-eventspy.jar\"
-Dfile.encoding=UTF-8
org.codehaus.mojo:exec-maven-plugin:1.2.1:exec\""
From that line I can tell that Netbeans:
goes to the project's directory
sets environment variables (JAVA_HOME and M2_HOME)
then executes cmd that executes mvn (by its full path)
with bunch of -D arguments (which specify working directory and AppStarter as a class to execute)
and exec-maven- plugin with target exec.
When NetBeans compiles a program it creates a folder-hierarchy with compiled .class files. When creating a JAR archive ZIPs those into the archive. When executing the program, (or debugging,) NetBeans runs the .class files off the folders, not in the JAR file.
These could cause different problems, like different PATH. This can cause "file not found" errors with relative paths.
what is your operatingsystem?
windows:
then wmic may be the tool, which could show you the complete commandline. you will find examples here command line of process by name
linux:
try
ps -ef | grep java

Running an executable jar file using Eclipse

I have a project file which includes a jar file(monix.jar) and some data(models, plugins, ...). Developers didn't provide source code of it and I need to run it.
I'm working in the eclipse env and I tried this steps:
extracted it in my eclipse workspace(it was extracted under a folder named monix)
in the eclipse:Run > External Tools > External tools Configurations
set location in the Main tab to: D:\eclipse workspace\monix\data\gate\plugins\ANNIE\build.xml (and ofcourse I tried this path too: D:\Program Files Project\Java\bin\java.exe) by Brows File System button.
then set Working Directory to the path of project folder. D:\eclipse workspace\monix by Brows File System button.
Developers have provided a syntax for running it ($ ./monix inputDirectory outputDirectory) so I set Arguments according to this syntax ($ ./monix D:\monixinputs D:\monixoutput)
When I run it, there is an error:
Exception occurred executing command line.
Cannot run program "D:\eclipse workspace\monix\data\gate\plugins\ANNIE\build.xml" (in directory "D:\eclipse workspace\monix"): CreateProcess error=193, %1 is not a valid Win32 application
I'm totally confused and really need your help,Thanks in advance.
File.jar
If you want only run the program you have to use this file. For run it open cmd or bash in Windows or Linux and write:
java -jar /Path_Of_Your_File/File.jar
(Be sure that you have environment variable "JAVA_HOME" correctly configured)
Build.xml
This isn't for run the program. This file is used, for example, for generate File.jar from the Java code.
Run --> Run configuration in Eclipse
Here you have to specify the name of your project and the name of the main class in your project, but if you haven't the code, you don't have to use this.
D:\Program Files Project\Java\bin\java.exe
This is java.exe, the virtual machine of Java, you don't have to execute this for run your project.

Running Eclipse from usb

I have put the necessary files on my USB pen drive, the Java Development Kit and the Eclipse files. I have created a .bat file which reads
#echo off
set Path=\32 Bit\jdk32\bin;%Path%
cd "32 Bit\Eclipse"
start eclipse.exe
exit
However when I run the batch, Eclipse launches and brings the error
As far as I can tell this is trying to use my old path variable for the JNI Shared Library. Could someone help me with this problem please.
It turns out there is a really simple solution to this.
Amended .bat file
#echo off
set Path=%~dp032 Bit\jdk32\bin;%Path%
cd "32 Bit\Eclipse"
start eclipse.exe
exit
Explanation
This works by getting the path of an executing batch file using the command %~dp0.
Where
d is the drive (in this case N:\)
p is the path (Code\Java\Eclipse Mars\)
0 is the name of the executing batch file
This path N:\Code\Java\Eclipse Mars\32 Bit\jdk32\bin which sets the Java version correctly and removes the error I had above
you don't need the batch script you can just change the -vm config directive and it will build the virtual machine from the exe for java you give it.
ex. -vm C:\jdk1.7.0_21\bin\javaw.exe. https://wiki.eclipse.org/Eclipse.ini#-vm_value:_Linux_Example

Categories