0

I have a java project in eclipse workspace which will create excel sheets with data. I have exported my whole project as a executable jar file which runs with the help of JVM on double clicking on the jar file. I can see a new process with javaw.exe getting created under the Processes tab in windows task manager, once double clicked on the jar. Question is, how to know if my java code has run and created the excel sheet with data.

I know, I can extract the jar content and check if the excel file is generated or not but I don't want to extract the jar all the time just to know if the code has done it's job or not.

Or is there another way to run my jar so that I can view the code getting executed?

I have no idea on this point, so no case of code research I can share with you.

Thanks in advance!!

Suresh
  • 1,491
  • 2
  • 22
  • 27

1 Answers1

1

I am assuming you create console application without any GUI. Otherwise you could just use the GUI.

You can run any java application from the windows command prompt using this command:

java -jar TheNameOfTheJarFile.jar

Then you will see any console output (System.out.print... or logging into console, if you used any) in the command prompt window.

Another (more ergonomic) way to communicate with the user is to use dialog windows. You would sprinkle your application with calls like this

JOptionPane.showMessageDialog(null, "Hello World!");

But be advised that if you display dialogs from the same thread that runs your program the dialog will block the execution until you click it off (OK, Cancel, X, etc.)

MatheM
  • 801
  • 7
  • 17
  • you are the boss.'java -jar TheNameOfTheJarFile.jar' is what I'm looking for. Now I'm able to see the execution of my jar file. Thanks a ton!! – Suresh Feb 08 '18 at 10:54
  • @mannedear If you want to run your application with the console open every time it can be useful for you to create a `.bat` file that runs the command for you, rather than typing it in every time. [This question](https://stackoverflow.com/questions/16543234/running-a-jar-file-in-a-command-prompt-from-double-click) deals with that. – MatheM Feb 08 '18 at 11:00
  • actually my code inside the jar ran into some trouble finding the file location which I mentioned in the code and failed to give me the expected output. That's how I got into a thought and wanted to check what's exactly happening inside the jar execution. Will post the issue in a different question if I don't find a solution here. May be you can help on that too. :-) – Suresh Feb 08 '18 at 11:05