1

I am trying to ship my Jar application using DVDs and need the user just to run an exe and launch the program. So I have written a batch file which runs the jar using the private JRE shipped in the same DVD.

Now when I run the batch file from the DVD it takes over one minute to launch the application because JRE is in the DVD as well.

When I copy the JRE in hard disk and use that in my batch file to lauch the program it runs fast. However I wouldn't the path where the user copies the JRE in his hard disk. How would I detect the same in my batch file ?

Neil
  • 5,919
  • 15
  • 58
  • 85

2 Answers2

1

I think that the best solution to your problem is to use a Java application installer, and to put the installer on the DVD. Some Java application installers include the ability to bundle a JRE, for instance Launch4J.

GreyBeardedGeek
  • 29,460
  • 2
  • 47
  • 67
  • I think you mean installer would copy the jre and program to hard disk during installation. But I need the jar and related resource to stay in the DVD itself only the jre to be in the hard disk for better launching time – Neil Nov 14 '12 at 04:40
0

OK, I'd suggest updating your batch script to look for JAVA_HOME. If present and equal or newer to the version you are running, then use that JRE instead.

See the following blog for instructions on how to do this. http://www2.hawaii.edu/~sdunan/study_guides/ics211/WindowsCommandLineCompiling.html

Tinman
  • 786
  • 6
  • 18
  • I'll add some sample code if I get time to come back to this question, meanwhile I thought I'd give you an path to start to follow. – Tinman Nov 14 '12 at 04:32
  • Thanks but what if JAVA_HOME is not set. it would start using the jre in DVD and slow down. Anyway to make sure JAVA home is set to begin with ? May be 1st time if Java home is not set it copies to jre to C drive and then next time onwards it launches using the same Java home? What do you suggest – Neil Nov 14 '12 at 04:43
  • You could do this, or you could include the jre installer, and launch that instead – Tinman Nov 14 '12 at 04:49
  • Thanks for the link, would the jre installer set the JAVA_HOME ? I was wondering what would my batch file know where the user copies the JRE in his local disk – Neil Nov 14 '12 at 06:25
  • 1
    If you launch the installer, you can test to see if it installed to the default location. 99% of users will install to the default location. However this assumes your user has administration access to their workstation. – Tinman Nov 15 '12 at 02:56
  • by Default location you mean "C:\Program Files (x86)\Java\jdk1.8.0" ? – Neil Nov 15 '12 at 06:19
  • Finally I settled with Launch4J , I think it tried to look for the defaults paths. – Neil Nov 15 '12 at 09:00
  • Cool, please post how that went as I have not used Launch4J, and if successful flag the answer by @GrayBeardedGeek as correct. – Tinman Nov 15 '12 at 23:56
  • Thanks but I was using Launch4J even before asking the question. I am still not able to launch the program immediately from DVD. I had no other choice and settled with Launch4J just to bring up a splash screen till the program launches after 3 minutes. Which is tool long wait. I am marked GrayBeardedGeek's answer useful. – Neil Nov 16 '12 at 03:35