实例jar文件(Snark客户端)

时间:2014-03-02 02:17:16

标签: java oracle client bittorrent

在Snark客户端网站(http://www.staging.threerings.net/snark.html)上,它说要实例化jar文件以加载客户端。我在oracle社区网站(https://community.oracle.com/message/8935199)上提到了这个问题,该网站说你可以用以下方式实例化jar文件:

Snark.main(args);

但是,当我使用上面的main方法调用运行我的程序时,它根本不显示我的GUI,而是在控制台中显示它:

The Hunting of the Snark Project - Copyright (C) 2003 Mark J. Wielaard

Snark comes with ABSOLUTELY NO WARRANTY.  This is free software, and
you are welcome to redistribute it under certain conditions; read the
COPYING file for details.

    snark: Need exactly one <url>, <file> or <dir>.
    Usage: snark [--debug [level]] [--no-commands] [--port <port>]
                 [--share (<ip>|<host>)] (<url>|<file>|<dir>)
      --debug   Shows some extra info and stacktraces
        level   How much debug details to show
                (defaults to 3, with --debug to 4, highest level is 6).
      --no-commands Don't read interactive commands or show usage info.
      --port    The port to listen on for incomming connections
                (if not given defaults to first free port between 6881-6889).
      --share   Start torrent tracker on <ip> address or <host> name.
      <url>     URL pointing to .torrent metainfo file to download/share.
      <file>    Either a local .torrent metainfo file to download
                or (with --share) a file to share.
      <dir>     A directory with files to share (needs --share).

然后我提到了这个网站(http://www.klomp.org/snark/),它给了我一个如何使用客户端的例子。给出的例子对我没有任何意义,看起来像命令提示。这是网站上的一个例子:

./snark somefile.torrent

我已经参与了几个星期,如何将snark客户端应用到我的程序中的任何帮助都会很棒。

1 个答案:

答案 0 :(得分:0)

我不确定你为args传递的是什么,但似乎程序没有得到任何参数,但它需要一些。为了模拟您显示的网站示例,只能以编程方式从您自己的程序中显示:

String[] args =  { "somefile.torrent" };
Snark.main(args);

如果您要传入特定文件,则可能必须使用绝对文件路径作为字符串值。重要的是main(args)采用表示命令行参数的String数组。因此,如果您要使用snark --debug 6从命令行运行Snark,则需要args{"--debug", "6"}

相关问题