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
Related
I am new to java but I managed to made a Java chat program. I exported it from Eclipse and now I hava two jar files; one for server side, one for client side. Unfortunatly I can't start it unless I open it with batch programm. I couldn't find a good answer how to make exe program in C# that will start this jar files.
Thanks for answers. If you want more infos ask and i will try to answer it.
When you export it, export it as a Runnable Jar file. This way, you should be able to double click on the file to make it run (if the computer has java installed of course).
Another option is to use Apache Ant, where you can customize your jar file and have more control than exporting from eclipse.
Hope this helped!
If you insist to start it through a c# application, you can use a simple winform with one button. In button click, you can do something like:
FileInfo fi = new FileInfo(directory);
//directory is the directory where the file is
//and the path is the whole path to the file, including the directory
if (File.Exists(path))
{
//start the file
System.Diagnostics.Process.Start(path);
}
else
MessageBox.Show("Sorry, the file cannot be found.");
EDIT: you can make it runnable in Eclipse, but it was a long time ago when I used it, so I don't remember anymore, but the others have given you suggestions.
There are programs that will allow you to wrap a Java application with an executable. In the past, I have had great success with JSmooth. This merely creates an EXE wrapper that calls the JRE to start your application.
There are also AOT (ahead of time) compilers that will make full-fledged executables, but I have no experience with them.
Jsmooth or Apache Ant will solve this problem.
just google it on how to use them.
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
I have a project in eclipse that uses rxtx. I have the same project in netbeans, too. They work perfectly, but neither of them works, when I create runnable jars.
I do not know what I do wrong. I tried to change classpaths, adding external libraries...
I must be doing something wrong, but can not not figure out what.
If there is out there somebody who managed to get rxtx work, can you explain step-by-step what to do?
See my answer here for a fuller explanation, but essentially you must extract the RXTX dll's (or so's, or other native libraries) from the JAR file and place them somewhere on the file system before you attempt to load them (which in this case involves initialising RXTX.) You cannot load the native libraries from inside the JAR file, it won't work.
However, you can have a JAR file that, when it runs, extracts the appropriate native libraries to a temporary location and then loads them from there. The libraries can be set to delete on exit of the VM so they don't end up clogging up the system.
I have a Swing desktop application and have created a jar file which depends on library (which is kept in ./lib/) and a .txt file in the same folder. Now to execute the jar I have written a .bat file which checks if Java is installed or not. If installed then I run the jar file with command:
javaw -jar TagEdit.jar
Now there are two problems I am facing with this:
I would rather prefer a single executable, if possible.
As using bat file, the console is visible in back (looks kind of weird). Is it possible to turn it off?
Java is everywhere, and there are lots of applications that are built in Java and packaged in a setup, or given as exe. I Googled a lot but could not find a way to create a setup for the software or an exe. How are those software packaged?
Have tried jlaunch, but could not get that to work correctly.
Himz, Eclipse can automatically build a so-called "fat-jar" for you. It is a jar that contains all the dependencies you need.
If you are a happy Maven user, then you have two brilliant alternatives - the shade plugin, and the assembly plugin. They both can produce a "fat-jar" for you. :)
There are various answers to this.
javaws.exe will execute the jar without the console appearing behind
But I feel this isn't really the best way.
I think should investigate using Java Web Start, So you create a JNLP file and have it jar downloaded from the web, I think, you can also have a desktop icon.
If you don't want that
I think you can get/buy binary wrappers for the jar.
You could convert it to an executable. Try Googling java to exe.
Once that is done, you could package it up as an installer using NSIS.
i have made an application using java....my source is in .java file ...now i want to create a setup file from these source files....
so can anyone tell me how i can make this setup files like another softwares...like device driver....etc...
please co-operate me....
Java can only be run on a machine with a JRE (Java Runtime Environment), so your setup file won't run quite the same as other application setup files; you won't be able to give someone your setup file and expect it to run correctly, unless they already have the appropriate JRE.
However, in Java, the usual way to do the "setup routine" is typically going to result in a "jar" file. Have a look at jar.exe (or "jar" if in linux/unix). It will chunk your classes into the appropriate container.
AdvancedInstaller offers features for installation of Java applications
Perhaps this will help you.