Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java program and Windows users

 
Ivan Witteveen
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to distribute a java program to Windows users, with XP or Vista. Say I have a .class file Test.class. Then I will do two things:

1) I'll tell the users to download and install java from www.java.com.

2) I'll supply a .bat file with the Test.class. What is the best command in this file: "java Test" or "start java Test"?

Will this garantee that the program will work for all users?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of messing with a script, package the classes in a jar file that you make double-clickable (by using the Main-Class attribute in the manifest). That will automatically start the JVM and run the main class.
 
M Brindamour
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's worth noting, though, that embedding other jars within your jar, and using them from your executable jar is not easy or well supported. If you need to do this, I would suggest looking for another solution. (app packager of some kind)
 
Andre Brito
Ranch Hand
Posts: 95
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ooopz.
The Jars' functions are that, Brindamour.
Ok, sometimes it can get a little hard, but I believe it's the best way.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't fully understand what Andre is saying, but let's not get sidetracked by jar files. They can easily be incorporated into the application jar file by unjaring/rejaring.
 
Andre Brito
Ranch Hand
Posts: 95
Java Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
I don't fully understand what Andre is saying, but let's not get sidetracked by jar files. They can easily be incorporated into the application jar file by unjaring/rejaring.


That's what I tried to say
Jars rocks (but some people just make their reputation looks like shit because they don't really know how to use them. I'm sorry but I'm a little bad with english :|).
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15358
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To make installation easy (so that your users don't have to manually download and install a JRE), you could use one of these installer generators to generate an installation program. Some of those in the list can automatically download and install a JRE if the user doesn't have it (or doesn't have the right version for your application).

You could also use Webstart (but your users will need to have Java already installed to use that).
[ July 14, 2008: Message edited by: Jesper Young ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic