-3

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.

Reporter
  • 3,897
  • 5
  • 33
  • 47
Jollyfreak
  • 39
  • 1
  • 6

4 Answers4

2

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!

hmnbvcxz
  • 56
  • 5
1

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.

Apostrofix
  • 2,140
  • 8
  • 44
  • 71
1

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.

Chris
  • 694
  • 3
  • 18
1

Jsmooth or Apache Ant will solve this problem.

just google it on how to use them.

Deepanshu J bedi
  • 1,530
  • 1
  • 11
  • 23