[英].java file not running properly using mac Terminal usual java commands
我正在嘗試在此鏈接中運行程序(特別是Plotter.java).zip文件中有關於如何運行它們的說明,但它們不起作用。我已經閱讀了有關從終端運行Java文件的其他問題並且我已經應用了這些解決方案,但是即使我已經運行了沒有任何問題的其他代碼(java -dir或javac),但都沒有對該文件起作用。 如何運行該程序? 我也想在eclipse控制台或eclipse制作的GUI中運行它(繪圖儀)。
ps:我沒有包含任何代碼,因為該程序有大約10個類,而且我對Java還是陌生的。
給定您發布的異常,問題是因為您沒有為Java提供正確的參數。 該程序至少需要三個雙精度參數。
他們是:
minX (the first argument)
maxX (the second argument)
frequency (the third argument).
根據.zip隨附的說明:PlotEq:
java PlotEq <min-x> <max-x> <sample-rate> <Expression>
Where:
min-x: is the minimum value of x to begin plotting
max-x: is the maximum value of x to plot up to.
sample-rate: how close points are plotted to eachother. A sample rate of 0.1 is generally acceptable, it means take a sample of the graph at 0.1, 0.2, 0.3, 0.4, etc. Basically determines how much detail to include in the plot
Expression: the equation to plot
example:
java PlotEq -5 5 0.01 "sin(x)"
plots sin(x) between x=-5 and 5, taking samples every 0.01 steps in x.
問題是由於缺少min-x,max-x和sample-rate的參數。
我試圖查看代碼,似乎您需要在命令行中輸入double而不輸入,因此它嘗試讀取空的args數組。 嘗試在您在命令行中執行三個雙打的類的名稱之后編寫代碼,它應該比它更有效。
如果要在Eclipse中運行,請在Eclipse的“使用”菜單中:運行->運行配置-> Java應用程序->鼠標右鍵單擊->新建->參數->添加一些所需的參數。
並且請仔細閱讀說明文件,其中說明了所有內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.