java - .java 文件无法使用 mac 终端常用 java 命令正确运行

标签 java eclipse macos terminal

我正在尝试运行 this 中的程序链接(特别是 Plotter.java)。在 zip 文件中,有关于如何运行它们的说明,但它们不起作用。我已经阅读了有关从终端运行 java 文件的其他问题,并且我已经应用了这些解决方案,但没有一个对这个文件有效,尽管我运行其他代码没有任何问题( java -dir 或 javac )。 我怎样才能运行这个程序? 我也想在 Eclipse 控制台或 Eclipse 中制作的 GUI 中运行它(绘图仪) .

p.s:我没有包含任何代码,因为该程序有大约 10 个类,而且我是 java 新手。

最佳答案

鉴于您发布的异常,问题是因为您没有为 java 提供正确的参数。该程序需要至少三个 double 参数。

他们是:

minX (the first argument)
maxX (the second argument)
frequency (the third argument).

根据 .zip 中附带的说明: 绘图方程:

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 和采样率参数造成的。

关于java - .java 文件无法使用 mac 终端常用 java 命令正确运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28508994/

相关文章:

c# - Visual Studio Code launchurl 不适用于 Web API

swift - 不确定的进度指示器没有动画

java - 当第一个场景失败时如何跳过所有 cucumber-jvm 场景

java - 如何将不同维度的数组输入到java中的方法中

eclipse - 如何在 Eclipse 中注释 block ?

java - Eclipse 提示 android 布局 xml 文件

java - 从 JFileChooser 获取用户输入的文件名

java - 主打印 null 和 0;而不是正确的名称;由于数组/列表问题

java - 关于Java语法的一些疑惑

android - System.getenv() 没有在 Android Studio 中提取任何环境变量?