2

在(Linux)命令行上,我使用包含空格的命令行参数启动 Java 类 je3.gui.ShowBean,方法如下:

    $ cd ~/workspace/JavaExamles/bin
    $ java je3.gui.ShowBean javax.swing.JButton 'text=Hello World!'

最后一个参数包含一个空格('text=Hello World!')。空格将命令行拆分为不同的参数。如果我想在参数中有一个空格,我必须引用参数或用反斜杠转义空格。

在命令行上运行的 main() 的参数是:

    args[0] = "javax.swing.JButton"
    args[1] = "text=Hello World"

但是当 gui.ShowBean 在 eclipse 中启动时,参数是:

    args[0] = "javax.swing.JButton"
    args[1] = "'text=Hello"
    args[2] = "World!"

这实际上不是我想要的。

如何在 Eclipse 中实现与命令行相同的行为?

4

1 回答 1

3

您确定在 Eclipse 中使用参数 text=Hello World! 运行 ShowBean!而不是“text=Hello World!”?

于 2013-01-09T09:34:34.897 回答