How do I read a Linux environment variable into install4j - install4j

My application sets CLASSPATH in a shell script named shrc that sets up the environment to run java commands. Is there an easy way to pass the CLASSPATH used in an installed application to install4j so I can use it in an action? The working solution I have uses "Run executable or batch file" to run a script that does this:
. ./shrc
${APPHOME}/jre/bin/java -cp ${CLASSPATH} ...etc...
I do this within an add-on installer, so the shrc already exists, but I need to run some of the existing java code to configure the patches.
It seems to me there must be a better way to do this that would work on Windows also. Any help is appreciated.

To read environment variables, use
System.getenv("CLASSPATH")
If you would like to use it as an install4j installer variable, add a "Set a variable" action with the above line as the script.

Related

How do I specify the java version to use with the Ammonite Scala shell on Windows?

I am working on an enterprise system where I can't control my system Path environment variable, and the system path points to a version of Java that is currently broken. I have another version of Java installed, and I would like to use that to run the Ammonite shell. Is this possible?
My hacky solution was to rename ammonite from amm.bat to amm-default.bat and create a new batch file called amm.bat that just adds my desired jre to the front of the session Path:
#echo off
set Path=C:\Users\bohlli\.jdks\corretto-1.8.0_292\bin;%Path%
amm_default.bat
I tried changing the path in the ammonite batch script itself, but every time I tried, something broke.

Is it possible to add a custom script fragment to the unix install4j uninstaller?

I would like to add a custom script fragment to the unix uninstall script generated by install4j. This is possible for scripts available under the launchers tab. Is this also available for the uninstaller? I'm using install4j 6.0.4.
Yes you can.
If you want to run shell script you need before the uninstall file step (because your script will not longer will be on the filesystem).
If you want to run Java code you can do it after the files deletion:
Add in the Run script step add you Java code.
This omission will be fixed in install4j 7.0.7 where installer applications will have a "Custom script fragment" property.
Please contact support#ej-technologies.com to get a build where this is already implemented.

Grails 2.3.1 in GGTS(Eclipse): Out of memory error when using run-script

I am executing a groovy script with run-script and running out of memory. I have found instructions for configuring ones GRAILS_OPTS on the command line, however I am not on the command line. How do I make sure that the grails command prompt in GGTS(Eclipse) is configured to provide enough memory for a script?
Just to be clear - this is a problem with run-script from the groovy command prompt inside The GGTS 3.4.0 release (Eclipse).
You can try setting the JAVA_OPTS system variable instead of the specific GRAILS_OPTS variable. It seems to work for me.
e.g
JAVA_OPTS="-Xms1024m -Xmx2024m -XX:MaxPermSize=512m"
For reference from grails docs - http://grails.org/doc/2.3.x/guide/commandLine.html, search for JAVA_OPTS. Depending on what OS you are on the syntax may be different.

check for JRE on system

I have an existing Java program that I am giving to some.... not so technically inclined clients of mine. They use a combination of Linux, Windows, and very few have apple machines, which is why I chose Java to develop the program in. The problem is they keep calling me with errors when they try to launch the program because they do not have a JRE installed. Is there any way to:
Import a lib that will give me some kind of command to check.
Add something to the program that will check for the JRE.
or (and I really don't want to go about this because of the reason I chose java in the first place)
Write something in C++ that will check for the JRE.
My aim:
Check if JRE installed on machine
If yes: Launch program
If no: pop up a message saying "No Java Environment found, downloading from Java website". Then I would take them directly to the link where they hit "run" and it installs.
// i would do something like
if (JRE.exists()) // maybe use a pathname that would only show up if a JRE is installed
{
// launch program
}
else
{
// launch Java installer
}
system.exit(0);
I understand this would be really hard in java (as you cannot run Java programs without a JRE) but I prefer to keep this universal if at all possible.
If there is no easy fix, I'll just make a read-me file that has the link to the java website that checks for a JRE on your system, but the least amount of work the user has to do the better.
I would suggest you use an Java installer like IzPack or other such free tools. Using one of these you can create an installer and also generate a native launcher. This can be configured such as it searches for Java and if not found, it can help the user installing it.
There are developers that also use JSmooth or Launch4J for native launchers.
check for JRE on system
Use deployJava.js as mentioned in the Java Web Start info. page.
..designed to ensure a suitable minimum version of Java is installed before providing a link to a JWS app. or launching an applet.
If it is a rich client desktop app. (e.g. applet or frame), deploy it using Java Web Start.
If you can't go with Java Web Start, although I'd recommend using it, you can write simple scripts to detect Java.
For Windows (.bat):
if not "%JAVA_HOME%" == "" (
"%JAVA_HOME%\bin\javaw.exe" -jar YourApp.jar
) else (
start http://java.com/download/
)
If JAVA_HOME environment variable is defined, then javaw.exe will be started with your application jar file. The javaw.exe executable uses window subsystem thus it runs without console window.
If JAVA_HOME is not set, it will open the Java download page in the default browser.
For more options, you can use JScript; with it you can display a warning to users that Java is not installed and then open the browser for download.
For Linux (.sh):
if [ "$JAVA_HOME" != "" ]; then
$JAVA_HOME/bin/java -jar YourApp.jar &
else
echo JAVA_HOME is not set: Java Runtime Environment (JRE)
echo is not installed your system.
echo Either install it from http://java.com/download/
echo or set JAVA_HOME environment variable.
fi
why don't you just create batch and bash files doing that and ask your customer to run one or the other dependently on the OS
if the JRE is installed on a system, then JAVA_HOME environment variable is set on both Windows and Linux and it contains the path of JRE. You can check if this variable is set and accordingly proceed.

'"php.exe"' is not recognized as an internal or external command

I am trying to create a new zend project using wamp.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\> cd wamp\www\zendtest*
C:\wamp\www\zendtest>C:\wamp\www\zend\bin\zf.bat create project quickstart*
'"php.exe"' is not recognized as an internal or external command,
operable program or batch file.
C:\wamp\www\zendtest>
I the environment variable path is
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\PROGRA~1\IBM\SQLLIB\BIN;C:\PROGRA~1\IBM\SQLLIB\FUNCTION;C:\Program Files\Zend\MySQL51\bin;C:\wamp\www\zend\bin;
Which is the part I think is wrong.
Replace this line in the zf.bat file
SET PHP_BIN=C:\wamp\bin\php\php5.3.4\php.exe
I too have come across the same Error when i started Zend. Here are some ways how to troubleshoot this.
Make Sure the PHP Interpreter Path (For Example, C:\wamp\bin\php\php5.3.8\bin) is set to the Environment Variables Path. Only one PHP Interpreter can be set.
Make Sure your WAMP Folder & the work directory (For Example, www directory) have valid permission set for proper Execution.
Make Sure your Antivirus/Firewall or any other Software is blocking the Access to php.exe. This i said because, in Windows 7 the User Access Control Feature will not allow execution of php.exe from command line.
And i suggest you work with NetBeans 7.2 which has built-in Support for Zend as well as Doctrine ORM. This is much easier. But you will have to execute the above techniques in that too in the Initial State. The Commands can be directly executed from NetBeans Context Menu.
Came across this error on a new installation even if I added the Environement Path to Windows.
If NetBeans is running, you need to start it as these variables are loaded on startup.