![](/img/trans.png)
[英]Unexpected outputs from two different ways of adding an ArrayList to another
[英]same script producing two different outputs with two different ways of execution in linux server
我有一個腳本,它有 java class 在這個腳本中被調用..但是這個腳本在 linux 機器中以兩種不同的方式執行時給出了兩個不同的輸出
第一種方法是如果我手動執行腳本。/test.ksh java class 成功執行並給出正確的 output
第二種方式我通過 cron 作業執行腳本然后它給出 java 錯誤UnsupportedClassVersionError
for java class 文件
我沒有對 java class 進行任何更改,但它以兩種不同的方式響應
很可能您在這台機器上安裝了兩個不同的 Java 運行時。
在 shell 用於您的手動腳本的 PATH 中找到了一個較新的。
從 cron 的環境中找到了一個較舊的。
Your java class has been compiled with a compiler newer than the cron-found Java version, but not newer than the shell-found Java.
A Java class compiled with eg Java 11 can not be executed by eg a Java 8, but by a Java 11 and later.
通過從 shell 和 cron 作業執行java -version
檢查版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.