LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 02-05-2013, 12:24 AM   #1
Brianlicorice
LQ Newbie
 
Registered: Feb 2013
Posts: 2

Rep: Reputation: Disabled
Smile How can I write a simple script to automatically run a java app?


hi guys, I need to write a script to run a java app automatically, all command lines should be included in the script. Necessary arguments like jdk location and output path are also needed. I've no experience of shell script, can anybody give a simple example for this? no 3rd party libraries.
Thanks!
 
Old 02-05-2013, 02:11 AM   #2
rigor
Member
 
Registered: Sep 2011
Posts: 153

Rep: Reputation: Disabled
Is the java app a single class file, or multiple class files?

If multiple files, will they all be in a single directory? OR, are you willing to package them in a single .JAR file?

In general, you can define a "variable" in a bash script, with a statement such as:

Code:
export VARIABLE_NAME=VARIABLE_VALUE
so on my system for example, I'd have:

Code:
export JDK_HOME=/usr/lib64/jvm/java
for the location of the JDK.

Then that could be followed by the command line for the java command, much as you'd type it, if you were manually trying to run the app from the command line.

But the specifics, such as mentioned towards the beginning of this message, can impact exactly what else might be needed in the script. Also, the exact situation/environment from which you intend to run the script, may affect what else might be needed in the script. Because in some situations, things which might be taken for granted in the environment which is present from the command line, might not normally be present, if the script is to be run from some automated facility in the "background". Additional details from you, could be quite helpful in order to answer your question as fully as possible.
 
Old 02-05-2013, 02:21 AM   #3
Brianlicorice
LQ Newbie
 
Registered: Feb 2013
Posts: 2

Original Poster
Rep: Reputation: Disabled
[QUOTE=rigor;4884593]Is the java app a single class file, or multiple class files?

If multiple files, will they all be in a single directory? OR, are you willing to package them in a single .JAR file?
QUOTE]

It's a single file and I'd like to make it a jar. I will need to pass an argument(which is the output path) for the main() using command line and setting up all other arguments. Please give me an example, I never did any shell script.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make my app automatically run on startup (Leopard Board Ti DM 368 ) peacemission Linux - Embedded & Single-board computer 10 05-29-2012 02:44 AM
How to write a script which will take in the password automatically? thomas2004ch Linux - Software 1 03-21-2011 12:11 PM
i need to write a script that automatically logins venix Linux - Newbie 3 03-03-2009 02:34 PM
want to write a simple app illtbagu Programming 9 04-08-2003 09:10 AM


All times are GMT -5. The time now is 05:21 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration