java


How can a script take different types of command line arguments and feed it to a java program?


So I need to make a java program that represents a bank tiller. However, I need to use an executable script that will feed the command line arguments to the java program. Unfortunately, there are multiple types of commands I can do that would need to call the java program.
Since there are different types of command options (start, buy, and change, I do not know how I could go about feeding the right argument information to the java program. Any assistance would be greatly appreciated.
Unless I'm missing something, you could use $# to pass the script's arguments to your Java program. For example,
#!/usr/bin/env bash
export CLASSPATH="$HOME/src/java/"
java com.example.MyTeller "$#"
Pass the script arguments to your Java program:
java programName "$#"
Here is a sample:
public class PrintArgs {
public static void main (String[] args) {
for (int x=0; x<args.length; x++) {
System.out.println(arg[x]);
}
}
}
Call it like this:
java PrintArgs start 80 = 10 2 2 2
The script I am not that sure about, but I you can look it up. Google shell scripts arguments.
Take a look at the Apache CLI stuff. Specifically the POSIX parser (http://www.javaworld.com/article/2072482/command-line-parsing-with-apache-commons-cli.html)
It will enable you to specify POSIX style command line arguments (--buy {value} --sell {value})...

Related Links

Using roo to create a springsource project with mongo
Thread after Service is destroyed
Android, best way to push data to a set of subscribed threads?
Change object type at runtime
Compiling with java version4.0
Where can I find the deprecated item's replacement in java?
Jboss 4.2 Class Loading
Restlet: GET requests using queries that access more than one resource
map action with struts.xml with multiple methods
in java,is there any easiest way to do tail -f functionality except common.apache.io.Tailer API
GWT SuggestBox: Rich suggestions instead of just text?
Getting value from multiple select in LIstbox ZK
Calculate Normal Distrubution using Java
Unmarshalling an xml element which is not part of namespace
How to port SWT to a new platform?
java garbage collection due to mulitly object reference

Categories

HOME
winforms
multithreading
date
gitlab
wso2
netbeans
tinymce
homebrew
view
at-command
yahoo-oauth
amortized-analysis
sharepoint-designer
ebean
ezpublish
wamp
datastax-java-driver
uber-api
paradox
gorm
gnupg
izpack
u-sql
google-cloud-ml
windows-azure-storage
size
openrefine
solaris-10
beyondcompare
lucene.net
riot.js
clickonce
orleans
h2db
shopware
pepper
nat
tinymce-4
iframe-resizer
ecto
catch-all
asset-pipeline
xmlreader
mmenu
nssegmentedcontrol
wpf-controls
vxworks
hue
greenrobot-eventbus
ruby-on-rails-3.1
elmah
texmaker
firebase-admin
vao
outlook-api
sas-jmp
flickr-api
termination
tactic
windows-mobile-6.5
mcafee
iso8601
spring-cache
sonarlint-vs
nested-sets
color-picker
pcf
gridview-sorting
jwplayer7
skype4py
essence
ptrace
associative-array
eclipse-clp
feedback
fouc
citrus-pay
emailrelay
event-bubbling
sankey-diagram
block-device
nsbutton
xojo
valueconverter
kgdb
industrial
spring-io
eclipse-memory-analyzer
hungarian-algorithm
interface-orientation
datawindow
labwindows
ocx
vdsp
iphone-web-app
jmock
datareader
yslow
wise
mtj
uimenucontroller
avatar
anti-piracy
signal-handling

Resources

Encrypt Message