I am under the impression that Launch4J cannot create launchers for OS X. Correct me, if I am wrong.
I would like to use something similar so I can set the initial heap size/ max heap size for my Java application without using command line options (java -jar -Xmx1024m etc....).
Any recommendations?
What you want is an Application Bundle. It include a properties file (Info.plist) where you can set things like Xmx, etc.
You can also use Oracle's appbundler tool to create an application bundle.
Another no-brainer option is to create a shell script. Something like this:
#!/bin/bash
java -jar myJar.jar
Eclipse can export a run configuration as a runnable jar file or a Mac OSX application bundle.
In the run configuration, add the command line options to the VM arguments textbox in the arguments tab.
Related
I'm trying to export my application to a JAR file. The program uses a lot of memory, so I used -Xmx1500m in Eclipse to make it work. It works when I export it (no errors), but it says VM arguments will not be part of the runnable JAR. How can I add the -Xmx1500m to my application outside of Eclipse? I tried a batch file with java -Xmx1500m but it didn't work. Any suggestions?
Try to use something like this:
java -jar yourJarName.jar arg1 arg2
I have to get some kinks out of a shell script for work, and one of the line looks like this:
-cp: this is the classpath
This is the set of classes that are used when running a specific class.
In your example; OrganT.Tune.Mix OrganT must be a class in the classpath (in this case, inside the OrganT.jar
Read the documentation, can be found here
Just a hint - under linux and mac you can use the
man <command goes here>
comman in the terminal/shell to display all parameters and usage information available for the specific command.
-cp stands for classpath. The CLASSPATH variable is one way to tell applications, including the JDK tools, where to look for user classes.
java -classpath .;YourJarFile.jar
I think you want to run a script for including the class path and execute the jar.
To do this in any text editor type java -jar YourJarFile.jar and save it, with extention (anyName.sh) assuming you have got linux flavour. Make it executable using the command chmod 775 anyName.sh
For windows type java -jar YourJarFile.jar, and save it with extention (anyName.bat)
I want to write an sh file that will set classpath in Linux.
I tried using:
export ClASSPATH=$CLASSPATH:$ABC_HOME
However, when I run the .sh file it doesn't set the classpath.
Executing the bash script only sets the environment for the child process. The "source" command may do what you want...
https://askubuntu.com/questions/53177/bash-script-to-set-environment-variables-not-working
You should make it a shell function, or source it. Because the environment variables are local to the shell (the one started by invoking your shell script).
Please read the advanced bash scripting guide. See also this answer to a similar question.
I developed a project using Java and now I've to deliver it to client who is using Linux. Which executable file format will be delivered and how to make that?
Executable file format?
If you're delivering a Java app, give them a jar file (and associated libs).
Provide a shell script to set up its environment and execute it.
For example, assuming I define ROOT_DIR as my app's install directory, and so on:
CLASSPATH="${ADD_JARS}:${CLASSPATH}:${ROOT_DIR}/lib/myApp.jar:\
${ROOT_DIR}/lib/jibx/jibx-run.jar:\
${ROOT_DIR}/lib/jibx/xpp3.jar:\
${ROOT_DIR}/lib/bindings.jar:\
${ROOT_DIR}/lib/commons-lang-2.0.jar:\
${ROOT_DIR}/lib/forms-1.0.5.jar"
"${JAVACMD}" -Xmx256M -DanyDefsNeeded=foobar -Dbase.dir="${ROOT_DIR}" -cp "${CLASSPATH}" myApp.main.Launcher "$#"
What goes into the shell script depends totally on what your app actually needs to start up.
A jar. If it is not executable, then a script (.sh) to launch the jar.
Well basically what you wanna put in a .sh file is the commands you'd normally type at the console to run your jar file. They should be separated by a new line (i.e. each on a separate line in the .sh file).
The most basic you can go is add something like this to your sh file:
java -Xms=64m -Xmx=256m -jar myJar.jar -classpath [dependencies dir]/dep1.jar,[dependencies dir]/dep2.jar
beyond this you can do more exotic stuff, like parametrise some environment variables, get command line argumens from when the .sh is launched and pass them to the jar executatble etc. Look up "bash scripting" for advanced stuff:
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-2.html#ss2.1
You might have better luck using Launch4J, IzPack or other installer that has cross-platform capabilities. This might be a better first option than trying to understand the intricacies and idiosyncrasies of the different Linux distributions and shells.
If your app. has a GUI, the best user experience for installation/deployment can be had by way of Java Web Start. Note that JWS can deploy apps. to Windows, *nix and Mac. and avoids all the maintenance woes of generating 3 separate (platform specific) executables.
I need to pass a couple of JVM arguments to the JVM which Tomcat is running in so that my application can pick them up.
I want to follow the process outlined in this article to pick up environment variables.
How would I go about doing this?
UPDATE
Sorry This is running under windows (7 on my Dev machine 2003 on client server)
Windows:
In your Tomcat /bin folder, you should have a tomcat5w.exe admin app (or in later versions tomcat6w.ex, tomcat8w.exe, etc). Go to the Java tab and add the args in the "Java Options:" box.
Note that when you add new args, you need to add them as NEW LINES in that box (above or below any others there), not as additional arguments IN FRONT or BACK of values on one of the existing lines.
Linux / UNIX:
In *nix, changes to the setenv.sh file should be picked up:
export JAVA_OPTS=-server -Xms2g -Xmx4g -XX:PermSize=64m -XX:MaxPermSize=256m $JAVA_OPTS
Don't touch catalina.sh or other files in bin
You need to edit the Windows service. There are three ways to do this:
Start Tomcat5w with //MS//ServiceName to get an icon in the system tray which gives you a quick access to the configuration of the service.
Open the service manager in the "Control Panel". There is an entry for Tomcat.
In the editor, there is a tab where you can add additional JVM parameters.
The third way (which I prefer) is to write a script which edits the config for you. This way, you can save the config somewhere for backup. See the docs how to do that (Hint: use tomcat5 //US//...)