I obtain different results using the same program when I run it thru:
1)..\Desktop\app.jar
2)..\Desktop\java -jar app.jar
second case gives the same result that I saw in eclipse but it uses console.
Question is: How do I force my program to work properly (to give the same result as in eclipse) by direct executing app.jar (without console)?
Asked
Active
Viewed 148 times
1

Andy Obusek
- 12,614
- 4
- 41
- 62

31415926
- 3,811
- 7
- 47
- 78
-
When you say properly I assume you mean get a console window to show when the jar is executed? – Name Dec 19 '12 at 00:50
-
I don't think it's possible. You'll have to make your own console using swing or something. – Name Dec 19 '12 at 00:56
-
Please post SSCCE sscce.org – Michael 'Maik' Ardan Dec 19 '12 at 00:59
-
When I say properlt I mean work the same way as in eclipse. and I really don't need a console while it running. SSCCE is not possible because it's a big project and I can not find the problem because I need at least console for tracking but when I start to use console it starts to work perfectly. – 31415926 Dec 19 '12 at 10:44
1 Answers
3
Use javaw
instead of java
in command line:
..\Desktop\javaw -jar app.jar
More information: http://docs.oracle.com/javase/1.4.2/docs/tooldocs/windows/java.html

tcb
- 2,745
- 21
- 20
-
Thanks. this solved my problem. Is it possible to make the call "\javaw -jar app.jar" using dobble clicking on .jar file? – 31415926 Dec 19 '12 at 10:59
-
that is good but my program should work in any other computer and I think it's not a good idea to change windows settings for the doubleclicking on every PC. Also it's not good to force users to start it thru command line. Is it bossible to indicate this information somewhere in .jar package or I necessarily have to make batch files for that? – 31415926 Dec 20 '12 at 13:17
-
You can create a batch file or you can wrap a jar into exe, but this will work for Windows only. See http://stackoverflow.com/questions/147181/how-can-i-convert-my-java-program-to-an-exe-file – tcb Dec 20 '12 at 15:30