我想從shell腳本調用java jar。它適用於windown批處理腳本。我試圖將這個工作批處理腳本翻譯成一個shell腳本,但是沒有得到它的工作。錯誤在哪裏?從shell腳本中調用java應用程序
原來的批處理文件(完美的作品):
@echo off
rem set the right host here
set host=example.com
set port=8080
set urlPartBeforeApiVersion=/project/api
rem geographical region
set west=47.358352
set south=8.493598
set east=47.406704
set north=8.560889
set numberOfVehicles=10
set idPerfix=SIM_KSDN128D
set vehicleSpeed=40
set gpsSendInterval=10
set cloudmadeApiKey=kldhfjsghjf83hf83hf83hf89whs89
java -jar %~p0dist/application.jar %host% %port% %west% %south% %east% %north% %numberOfVehicles% %idPerfix% %vehicleSpeed% %gpsSendInterval% %urlPartBeforeApiVersion% %cloudmadeApiKey%
pause
shell腳本(不工作):
#!/bin/sh
host="example.com"
port="8080"
urlPartBeforeApiVersion="/project/api"
west="47.358352"
south="8.493598"
east="47.406704"
north="8.560889"
numberOfVehicles="10"
idPerfix="SIM_KSDN128D"
vehicleSpeed="40"
gpsSendInterval="10"
cloudmadeApiKey="kldhfjsghjf83hf83hf83hf89whs89"
java -jar $(dirname $0)/dist/application.jar $host $port $west $south $east $north $numberOfVehicles $idPerfix $vehicleSpeed $gpsSendInterval $urlPartBeforeApiVersion $cloudmadeApiKey
應用程序會引發一個Java NumberFormatException異常並退出。我在Windows 7和Centos上測試了cygwin上的腳本。
粘貼完整堆棧跟蹤,你傳遞錯誤的應用程序不期望 –
你得到什麼錯誤? – drvdijk
「xception in thread」main「java.lang.NumberFormatException:For input string:」8080 at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java。 lang.Integer.parseInt(Unknown Source) at application.Application.main(Application.java:36) –