DHIS-lite and check for Java

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.

Knut

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?

Regards
Bob

···

2009/8/18 Knut Staring knutst@gmail.com

Knut


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

OK will fix this. The sample database included should also be brushed
up a bit, will do it in one go.

Lars

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?

···

2009/8/18 Lars Helge Øverland larshelge@gmail.com

OK will fix this. The sample database included should also be brushed

up a bit, will do it in one go.

Lars

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.

···

2009/8/18 Lars Helge Øverland larshelge@gmail.com

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.

Sure.

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.

Hi,

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

My Tech Blog: http://sunnytalkstech.blogspot.com

You Live by CHOICE, Not by CHANCE

2009/8/18 Lars Helge Øverland larshelge@gmail.com

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.

Sure.

I have tested things on Windows 7 today. Running dhis2 lite +

building/testing the source code work just fine.


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

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.

Regards
Bob

···

2009/8/18 Saptarshi Purkayastha sunbiz@gmail.com

Hi,

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

My Tech Blog: http://sunnytalkstech.blogspot.com

You Live by CHOICE, Not by CHANCE

2009/8/18 Lars Helge Øverland larshelge@gmail.com

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.

Sure.

I have tested things on Windows 7 today. Running dhis2 lite +

building/testing the source code work just fine.


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp

oops sorry. forgot the list …

···

---------- Forwarded message ----------
From: Bob Jolliffe bobjolliffe@gmail.com

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 …

Cheers
Bob

2009/8/18 Bob Jolliffe bobjolliffe@gmail.com

? Maybe vuze is smaller - I haven’t looked yet.

I see vuze is an example of the technique. Not a tool to do the job …

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

My Tech Blog: http://sunnytalkstech.blogspot.com
You Live by CHOICE, Not by CHANCE

2009/8/18 Bob Jolliffe bobjolliffe@gmail.com

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.

Regards
Bob

2009/8/18 Saptarshi Purkayastha sunbiz@gmail.com

Hi,

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

My Tech Blog: http://sunnytalkstech.blogspot.com

You Live by CHOICE, Not by CHANCE

2009/8/18 Lars Helge Øverland larshelge@gmail.com

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.

Sure.

I have tested things on Windows 7 today. Running dhis2 lite +

building/testing the source code work just fine.


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp


Mailing list: https://launchpad.net/~dhis2-devs

Post to : dhis2-devs@lists.launchpad.net

Unsubscribe : https://launchpad.net/~dhis2-devs

More help : https://help.launchpad.net/ListHelp