I don't want to run my Java program in Eclipse, I want to run it on my desktop like normal program, because I will present it so that it should not looks like amateur.
How can I convert it to desktop application type program?
well, this is somewhat complicated question. when you compile you actually create a jar file, that you can run like a "normal" program. you can take that jar and run, but you need to know that your project my have dependencies on other .jars, pictures, or other type of files. therefor it may be a bit complicated. you can read more about it here or here.
here is a question about making .jar with files(pictures). you might need it
If you want to convert your .jar file to an "executable"/"ready to run file" look at these possible solutions.
It depends on if you are using mac or windows. I have a mac, and I just created an AppleScript to open my .class file that said:
do shell script "cd [filepath]
java [filename]"
and then saved it as an application and changed the icon, I don't know about windows though
Related
I've converted a jar application to an exe because I want to execute this app on computers which not have installed java.
But the .exe file (the old jar) still want JVM or will be executed by Windows?
It depends entirely on whether the method you're using to convert your JAR to an EXE includes the Java runtime in (or alongside) the EXE. If it doesn't, it will have to locate the JRE on the computer it's executing on.
If you feel like elaborating a little, perhaps we can give a more detailed answer.
The implication in the question is that the .jar file was simply renamed to have a .exe extension. If this is what was done, it will not work.
To package a .jar as a .exe that includes its own jvm, look at tools like:
https://www.duckware.com/jexepack/index.html
http://www.jar2exe.com/
http://launch4j.sourceforge.net/
I've created a program in java and now I want to create an executable from it.
I'm new to java, I don't know if it should be a .exe.
I'we exported my project to a .jar file, but when I double-click it it opens "open with" window.
I want to export my project to a file that runs my program on double-click.
Is there any solution?
Export --> Java --> Runnable Jar file --> Specify the class with static main method to run.
Double click on the Jar file to run..
Thanks...
Java compiliation creates byte code for the JVM, so a native, binary executable is not created during compiliation (like C or C++ programs). This is a feature of Java.
To deploy an application to multiple systems they must have the JRE. These .jar files can be launched from the command line (see this: http://download.oracle.com/javase/tutorial/deployment/jar/run.html)
Some vendors get around this with batch files that launch the JRE to run their application's JAR (and then put these in the start menu, desktop, etc with a fancy icon).
If you want people to install your app (especially from a web page or over a network) you probably want a Java Web Start package (see this for crating one in Eclipse: http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fjava_web_start.htm)
If you just want it to be runnable on your computer, you can use the open with dialog to open it with javaw.exe in JDK_DIRECTORY\bin. Alternatively, if you really wanted to make it an EXE, you could look at some of the answers here.
Either do as in the link mentioned by #dacwe or I would suggest to depending on operating system set a permanent connection between java and jars, then it will always happen.
On Windows you do it by right clicking on any jar then open with and find your javaw.exe in bin folder of your jre installation.
I think you are looking for a simpler approach than Java Web Start.
I assume that you are a Windows User, since you want a .exe file.
So once you have the exported MyProgram.jar file, you only need to create a .bat file
that contains a sole line:
java -jar MyProgram.jar
and place this execute.bat file in the same folder as your MyProgram.jar
This approach works for Linux too, only you need to place it inside a similar file and execute the same command.
Read here http://javabeanz.wordpress.com/2009/01/29/running-an-executable-jar-from-command-line/ for more explanations.
I'm new to java and have recently created a stress testing application to test server configurations. Its very simple and all is done within cmd line. I used eclipse to create the jar file and that seems to have worked fine.
The problem that I am running into is making this executable. If I use java -jar in windows cmd line to execute the program, it runs fine. However, I need to be able to run it by "double clicking" the jar file(right now I click on it and nothing happens) or create a .exe which defeats the purpose of java, but this will only be used in windows.
When I click on the jar now nothing happens, but when using the java - jar in cmd it works. Not all of the computers have java in the cmd line, but have it installed. I'm not sure why a cmd window doesnt pop when clicking on the jar?
Again I'm new and any help is much appreciated!!
Create a sortcut icon that will do java -jar yourFile.jar
In windows, you can associate the jar file with the JRE jar runner. Take a look at this post, which explains your options pretty well.
Make a bat file for Windows. You can do this by the following:
#echo off
java -jar YourJarName.jar
Save this in a text file with the .bat extension.
It should run the JAR once double clicked if the JAR file is in the same directory as the .bat file. Otherwise you will have to navigate to the JAR file relative to where the .bat file is located.
You said you didn't want an exe but not sure if this will be ok for you. It shouldn't be a problem for someone to click the .bat file first and will work in all cases under Windows.
Hope this helps.
If you want to get really awesome with it and have it show up in your Task Manager with an app.exe naming and handle any startup options, you should read into JNI. JNI will allow you to wrap the starting and stopping of a Java app using a windows executable and it is actually very simple to implement.
If you want something as simple as a windows exe launcher, there are also tools out there such as Launch4j will create exe wrappers for you.
I wrote a simple synth instrument gui that works well on my machine. However, as soon as I put it in a jar file, it no longer plays sounds when executing that jar file. I assume that has to do with the soundbank. Either way, I cannot get it to play a note on my machine when I run the jar file, so I presume it will not work on another person's machine. Any thoughts as to what might be going on? Thanks.
-Matt
did you pack in .jar file even sounds that should play?
How do you run your .jar file?
Something about resources in your .jar file (what could be your case) you can read here.
About running .jar files and troubles with them you can read here and here.
Good luck and let us know if it helps you.
You are probably running your tests in an IDE using the java JDK but testing the app from the jar using the JRE.
See on how to fix it: http://www.jsresources.org/faq_midi.html#jre_soundbank
everyone, how can I create executable file for the program written on Java in Eclipse Helios? I mean to create small icon to be able start program only by double-clicking on its icon, thanks in advance
edited
I mean executable for Windows
Export .jar in eclipse. (how to)
Use JSmooth (info) to make an .exe file. (how to)
Here is a tutorial that shows you how to make a jar file from eclipse.
If Java is installed on the computer, you can execute your application by doubleclicking the jar file:
http://ecs.victoria.ac.nz/Courses/COMP205_2009T1/TutorialEclipseExportToJar
You didn't mention what platform you are using. There are 2 ways I can think of.
The easiest way is for you to create a *.bat file (in Windows) that contains the java YourApp command line.
If you want to create a more fancy installer and executable, you can use NSIS script to do so. Since you are using eclipse, consider trying EclipseNSIS to generate the NSIS script, which is much faster and easier than writing it yourself from ground up.
The best answer for this situation is to launch the app. using Java Web Start. JWS can not only create desktop and start menu launch items, but provides automatic updates, cross-platform compatibility and much more.
Create a 1-line metafile to specify which class the JVM should look for to start with the main(String[]) method.
Run the command jar cmf [metafileName] [jarfileName] [classfiles] [img/txtDirectories]
You have an executable jar file - type in "java -jar jarfileName" or, directly "jarfileName" at your prompt. On windows, you can also double click on the jar file logo/name to get it started.
Good wishes, - M.S.
PS: Here is the link to a more detailed tutorial:
http://csdl.ics.hawaii.edu/~johnson/613f99/modules/04/jar-files.html