• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Linux script to call a java program

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am a linux newbie but I want to call java program from a script that I would to run at startup. ( place in /rc?)

it is a bash shell and is it also possible to pass variables to the java program when it is called?

thanks
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like I already answered part of this here. Please don't post the same question to multiple forums -- it just wastes people's time.
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have written a couple of shell scripts to run command line java programs from linux. One of the benefits I've found is that I can pass additional arguments to the jvm and use the script to pass environment variables to the jvm as system properties. Here's an example script I wrote:



This illustrates both features I described earlier. I have set the maximum heap size to 256 megabytes, and the script checks for the existance of the environment variable MOLDATA which it passes to the property devries.radxfer.moldata if it exists. the "$@" means insert the script's command line arguments here.

To create an rc script I would take a look at your system's init.d scripts and use a similar format. Debian provides /etc/init.d/skeleton as an example init.d script which uses their start-stop-daemon program to start and stop your daemon.

Good luck.

Chris
[ April 19, 2005: Message edited by: Chris De Vries ]
reply
    Bookmark Topic Watch Topic
  • New Topic