Here is the current content of startup.bat for DHIS-lite:
@echo off
if not “%JAVA_HOME%” == “” goto startup
:abort
echo DHIS 2 requires a Java Runtime Environment to be installed
pause
goto end
:startup
echo Starting DHIS 2…
java -jar dhis2-lite.jar
goto end
:end
Unfortunately, this way of checking for Java is too assiduous, it will give error messages in all those common cases where people in fact have Java installed, but JAVA_HOME is not set (as is the case e.g. with Synergy machines at the WHO). We should fine a different way of detecting whether Java 1.6 is available.
Here is the current content of startup.bat for DHIS-lite:
@echo off
if not “%JAVA_HOME%” == “” goto startup
:abort
echo DHIS 2 requires a Java Runtime Environment to be installed
pause
goto end
:startup
echo Starting DHIS 2…
java -jar dhis2-lite.jar
goto end
:end
Unfortunately, this way of checking for Java is too assiduous, it will give error messages in all those common cases where people in fact have Java installed, but JAVA_HOME is not set (as is the case e.g. with Synergy machines at the WHO). We should fine a different way of detecting whether Java 1.6 is available.
True. In fact we have no need for JAVA_HOME to be set at all.
I am not a windows batch file wizard but I’m guessing we just need to run ‘java -jar dhis2-lite.jar’ and catch any error which might have occurred on the next line.
Or else try first to run something like ‘java -version’ first and then continue on the basis of that being successful.
I wonder how do other applications do it on windows?
given that its an executable jar, do we even need a batch file at all? Assuming java is installed on the host machine won’t it just start by double clicking on it? Or should we be trying to catch and report the situation that java is not installed?
Yes it will start, we can just leave out the bat file. We can make the
java requirement clear on the website.
···
2009/8/18 Bob Jolliffe <bobjolliffe@gmail.com>:
given that its an executable jar, do we even need a batch file at all?
Assuming java is installed on the host machine won't it just start by double
clicking on it? Or should we be trying to catch and report the situation
that java is not installed?
Yes it will start, we can just leave out the bat file. We can make the
java requirement clear on the website.
A minor pitfall is that the jar file might on windows be associated
with a compressing software like winrar or winzip. But we can make
this clear as well.
Mind you … though we don’t need JAVA_HOME there might be a case for setting JAVA_OPTS. Maybe we just need an explanatory note on the website about production-vs-demo and tuning.
I have tested things on Windows 7 today. Running dhis2 lite +
building/testing the source code work just fine.
···
2009/8/18 Bob Jolliffe <bobjolliffe@gmail.com>:
Mind you ... though we don't need JAVA_HOME there might be a case for
setting JAVA_OPTS. Maybe we just need an explanatory note on the website
about production-vs-demo and tuning.
This issue has been solved by a number of Java projects and we have seen the pitfalls of using jar files for distribution in all these projects. Native executables are easiest and best way to solve this problem. The logic to identify java, version, location, operating system should be done in these native launchers or initialization class whichever is practically doable.
For examples, I would suggest looking at Netbeans or Vuze.
···
Regards,
Saptarshi PURKAYASTHA
Director R & D, HISP India
Health Information Systems Programme
OK cool. I figured this problem must be well solved by now. Wrapping in a native executable sounds like a smart way to go (much like tcl distribution with starkits and tclkits).
Saptarshi do you know is there a simple way to do this, preferably using maven, which doesn’t necessarily involve another massive dependency (like netbeans in this case)? Maybe vuze is smaller - I haven’t looked yet.
This issue has been solved by a number of Java projects and we have seen the pitfalls of using jar files for distribution in all these projects. Native executables are easiest and best way to solve this problem. The logic to identify java, version, location, operating system should be done in these native launchers or initialization class whichever is practically doable.
For examples, I would suggest looking at Netbeans or Vuze.
Regards,
Saptarshi PURKAYASTHA
Director R & D, HISP India
Health Information Systems Programme
Date: 2009/8/18
Subject: Re: [Dhis2-devs] DHIS-lite and check for Java
To: Saptarshi Purkayastha sunbiz@gmail.com
I see there are a number of examples of these jvm wrapper programs - for instance this oldish looking one - http://jsmooth.sourceforge.net/. One drawback I see is that the jre must presumably be embedded and distributed in the executable. dhis2 ‘lite’ is already pretty large. Also I wonder about the question of java opts? Perhaps the settings are somehow mangled into the executable.
I can see us opting for a range of download options …
Yes, Vuze and netbeans are examples and not dependencies…really small files They can be automatically created to wrap the jar and these projects can do it using a build tool like ant/ivy/maven
···
Regards,
Saptarshi PURKAYASTHA
Director R & D, HISP India
Health Information Systems Programme
OK cool. I figured this problem must be well solved by now. Wrapping in a native executable sounds like a smart way to go (much like tcl distribution with starkits and tclkits).
Saptarshi do you know is there a simple way to do this, preferably using maven, which doesn’t necessarily involve another massive dependency (like netbeans in this case)? Maybe vuze is smaller - I haven’t looked yet.
This issue has been solved by a number of Java projects and we have seen the pitfalls of using jar files for distribution in all these projects. Native executables are easiest and best way to solve this problem. The logic to identify java, version, location, operating system should be done in these native launchers or initialization class whichever is practically doable.
For examples, I would suggest looking at Netbeans or Vuze.
Regards,
Saptarshi PURKAYASTHA
Director R & D, HISP India
Health Information Systems Programme