EXE (C#) program that will start java Chat - java

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.

Related

Java application deploy

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.

How to create an executable (a file that starts the program on double-click like an .exe) in JAVA with Eclipse?

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.

Java MIDI Synthesizer .jar not playing

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

how can I create executable file for the program written on Java?

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

how to make setup file

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.

Categories

Resources