How can I make an executable file with java netbeans? - java

How can I make an executable file with Java using NetBeans IDE that file work on computer or mobile. I create jar file but I don't know why it did not work.

You can run jar file in case its manifest contains proper reference to class with main() function using command java -jar jarfile.jar. If you need Windows executable, you can use launch4j. For Android AFAIK you need to build apk file.

Related

How to execute .exe from within runnable jar file

I am working on a Java desktop application and want to execute an .exe file upon some user action.
I want to package the .exe inside the executable jar so that I have to ship just one item to my customer/user. But so far I have not been able to execute an .exe file which is packaged inside the jar.
One more input, the .exe in turn uses a bunch of .dll, .xml and .exe files (total 12 files), so I need to package all of them to make this work. Is this possible in java or should I use another language to achieve this?
I chose java because I want to support Mac platform also. So with these .exe and .dll files (for Win), I need to package and execute a bunch of Unix executable files and dylib files also (for Mac).
What would be the best way to achieve this?
I can think of 2 ways:
Make one Java executable app and dynamically execute exe or Unix executable file depending on platform it is running. The problem here is executing the files which are packaged within the jar.
Make separate applications for Win and Mac. In this case, which languages should I use?
Thanks much for the help!
Applications are packaged very differently on windows and mac. For the Windows version I would recommend you to distribute an installation program (see IzPack for instance) that will unpack the jar and the exe in the application directory (I don't believe you can directly execute an exe that's in a jar file). A MacOS application is actually a directory with a certain structure, so in your case, the said directory could contain both the jar and the exe.

Running a class that relies on Jar file in terminal

For my intro computer science class they recommend using eclipse as an IDE. I have used vim in the past and would prefer using it. There are two .jar files that the programs we create rely off of, because it is an intro class and we are not using java's main class functionality.
Right now we download the two .jar files and then use the Eclipse IDE build path function to link the .jar files with our code. Then when we run on Eclipse IDE it works perfectly fine.
How would I do this in ubuntu terminal? Thank you!
TLDR;
Intro comp sci class wants us to use eclipse, I want to use vim. How do you build path for a jar file to work with my class code in the ubuntu terminal.
Looked at this link and did not work
Java: how to import a jar file from command line
Update of image
You specify the jar files with a CLASSPATH, either using a CLASSPATH environment variable
export CLASSPATH="a.jar:b.jar"
java com.mypackage.MyClass
or on the command line with -cp like
java -cp a.jar:b.jar com.mypackage.MyClass
Include your jar dependencies while executing from command line.
java -cp tester.jar lab1

How to export my java program and open it in other computers? (Using Eclipse)

Is there any .exe file like those VB creates for you which can be opened in different computers without any other app? created or can be created by Eclipse? I didn't find a thing in the project folder.
Java uses the "jar"-files as a container for executable binaries. But they require Java beeing installed on the target computer.
In Eclipse you can export you application via File -> Export -> Runnable JAR file
Then you have to select the entry point (a class with a main-method) which should be called on running the jar-file.
On the target computer you can normally run the jar file by double-clicking it (Java SE is required to be installed). When that doesn't work you can manually call "java -jar container.jar" to execute the jar in the Java enviroment.
Jar files are used for deployment but in order to run them you need the jvm.
You can convert jar files to .exe .
I'm not sure if the conversion will result in the app running on computers with different OS'es (probably not) than the one in which the the .exe program was created in.
Here are some references
How to create an exe file in java.
How can I create a Windows .exe(standalone executable) using Java/Eclipse?.

Is it possible to create an .exe executable file using Java?

I am not talking about the executable jar file, instead the .exe file for windows can that be generated for Java apps. I know there is some projects like JSmooth etc., so I am a little curious to know how they create exe's for jar or class files.
Why not write a .bat file (windows script) that launches the executable jars? The effect will be the same: user double-clicks and launches the app.

Provide/Export executable file to client

I just completed working on a client's tool, which uses Jfreechart jar, and dll and a lib file for JNI interface. Now I would like to export/ provide a executable file to client, I tried to click on java project folder and export Java>Runnable Jar file (extract required libraries into generated JAR) , a Jar file is exported with some Warnings. However, we are not able to run the file on client's machine. How can I fix this, obviously I don't want to provide complete Java project and ask client to run from and IDE. Please provide me inputs.
Since Java is a cross-platform environment, it doesn't really have "executable files" like EXEs or anything. Instead, you run your .jar file with the Java runtime. For example:
C:\>java.exe MyProgram.jar
Of course some operating systems will just do this for you once the Java runtime is installed.
There are some programs to convert .JAR to .EXE, but I believe they just compile a thin wrapper that calls into the Java runtime.

Categories