• Post Reply Bookmark Topic Watch Topic
  • New Topic

Executable jar files with CLI programs?  RSS feed

 
Flo Powers
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I looked at the thread on creating executable jar files at http://www.coderanch.com/t/391746/java/java/Game-Tutorials-Creating-Executable-JAR and this worked fine for an application, but I don't know if it's possible to do the same with a program that runs in the command prompt. Any ideas?

Thanks!

[EDIT by mw: Repaired link.]
[ February 05, 2006: Message edited by: marc weber ]
 
Marilyn de Queiroz
Sheriff
Posts: 9082
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Flo Powers:
this worked fine for an application, but I don't know if it's possible to do the same with a program that runs in the command prompt.

Whether you run your application from the command prompt or from an IDE or from TextPad or from a bat file, it works the same way. I guess I don't understand your distinction between "an application" and "a program".
 
Flo Powers
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, careless wording on my part. What I mean is, I've made two different programs, one that displays a GUI using swing, and one that runs in the command prompt (or perhaps "console" is a better word for it?). I made two different executable JAR files (using Eclipse - really easy). However, when I click on the one that has a GUI, it loads fine. When I click on the one that requires a console in which to run, nothing happens.

Is there a(n easy) way to make this CLI program run when I double-click the JAR file?

Hope that was a bit more precise. Thanks again!
[ February 08, 2006: Message edited by: Flo Powers ]
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is probably a minor error -- but you can't see it, because windows terminates the cmd window as soon as the programs ends.

I suggest that you write a very simple batch file, with the single command:



The "/k" option will force the window to stay, so you can see what the error is.

Henry
 
Flo Powers
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your answer, but I'm afraid I'm going to need a bit more help.

I've never written a batch file, so... the line of code you wrote goes in the batch file?

Flo

Wow! I tested it - put the line in a text file (with the rigth jar file name), saved it as a .bat file and double-clicked it, and voila! It works!

THANK YOU! )
[ February 21, 2006: Message edited by: Flo Powers ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!