1

Possible Duplicate:
How do I create executable Java program?

I had implemented some speech recognition application in java.its working well with the eclipse when i run from eclipse..but my code not running when i m trying to run from command line ..

i had included some jar from the sphinx ..like sphinx.jar,jsapi.jar,wsj_dictionary.jar,my directory structure is as follows :

my directory structure

So can anyone suggest me how to make .exe or a executable jar file that can be run directly?

thanks in advance..

Community
  • 1
  • 1
BhavikKama
  • 8,566
  • 12
  • 94
  • 164

3 Answers3

5

In Eclipse, you can export your project into an executable JAR file by right-clicking on your source folder, selecting "Export...", selecting "Java->Executable JAR File". Eclipse will then offer the option to either extract your external JAR dependencies into the final jar file, or place them into a folder with the final jar's manifest classpath referencing them.

FThompson
  • 28,352
  • 13
  • 60
  • 93
  • 1
    *"either extract your external JAR dependencies into the final jar file, or place them into a folder with the final jar's manifest classpath referencing them."* The latter is much more versatile. It allows easy reuse of common APIs, amongst other benefits. – Andrew Thompson Sep 05 '12 at 05:09
  • i have done that way..but then when i run that jar file from command line its hows me errro like u cant access .jar file which i have created – BhavikKama Sep 05 '12 at 05:23
  • Thanx a lot I have succeeded..Its amazing .just a few minutes and you guyz Solved My problem..thanks a ton for that – BhavikKama Sep 05 '12 at 05:30
3

The MANIFEST.MF file in your jar should specify the Main-Class and the classpath. Something like this:

Main-Class: full.package.path.to.your.main.class
Class-Path: space separated list of jar files

You would probably want to use an automatic build tool like Ant, Maven or Gradle in order to generate the MANIFEST.MF file in your jar that way.

Dan D.
  • 32,246
  • 5
  • 63
  • 79
2

Use Launch4J for wrapping jars in Windows executables.

noclayto
  • 160
  • 1
  • 6