0

I have a java project which reads data from an the excel sheet (specified by the user), performs some filtering and creates a few text files and then writes the modified data to the text files.

The project is working fine and now I want to create a jar file for it. I created the jar file but it did not run. As far as the code is concerned it is running without any errors.I have used Netbeans for GUI. I also saw related questions which said it is not possible to create a text file from a running jar.

Is there a workaround?

Leigh
  • 28,765
  • 10
  • 55
  • 103
  • 1
    *"But I am facing some problems with this."* What problems? Copy/paste error or exception output as an edit into the question. Please don't assume we can read your mind or see your IDE. – Andrew Thompson May 18 '12 at 15:30
  • sorry for not specifying this. I created the jar file but it did not run. The code is running without any errors. – Sadia Khan May 18 '12 at 15:32
  • There are no errors in the code. I am just looking for a way to run my program from an executable jar file. – Sadia Khan May 18 '12 at 15:56
  • 1
    *But I am facing some problems with this.*: which problems? Any exception stack trace? What should the program do and what does it do instead? When you go see your doctor, you don't just tell him: "I'm sick". You go into details. You describe the symptoms. Do the same here. – JB Nizet May 18 '12 at 15:57
  • *"The code is running without any errors."* Are there any `catch` statements in the code? Run it from the command line using something like `java -jar our.jar` – Andrew Thompson May 18 '12 at 16:00
  • Just ran it from the command prompt. There was a problem with finding the main class. Because there were two classes with the main method. It worked after rectifying this problem. Thanks for the help :) – Sadia Khan May 18 '12 at 17:06

1 Answers1

1

You need to specify the main class in the manifest of the jar file.

If you have an application bundled in a JAR file, you need some way to indicate which class within the JAR file is your application's entry point. You provide this information with the Main-Class header in the manifest, which has the general form: Main-Class: classname

http://docs.oracle.com/javase/tutorial/deployment/jar/appman.html

sul
  • 267
  • 1
  • 9