当前位置: 首页 > 知识库问答 >
问题:

ant命令只返回java帮助文本

葛浩阔
2023-03-14

我能做什么?

当我键入“蚂蚁”或“蚂蚁版本”时,终端仅显示Java帮助(如“java -h”)。

有没有办法解决这个问题?

编辑:这是终端日志:

sebastian@sebastian-virtual-machine:~$ ant
Usage: java [options] <mainclass> [args...]
           (to execute a class)
   or  java [options] -jar <jarfile> [args...]
           (to execute a jar file)
   or  java [options] -m <module>[/<mainclass>] [args...]
       java [options] --module <module>[/<mainclass>] [args...]
           (to execute the main class in a module)

 Arguments following the main class, -jar <jarfile>, -m or --module
 <module>/<mainclass> are passed as the arguments to main class.

 where options include:

    -zero     to select the "zero" VM
    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    --class-path <class search path of directories and zip/jar files>
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -p <module path>
    --module-path <module path>...
                  A : separated list of directories, each directory
                  is a directory of modules.
    --upgrade-module-path <module path>...
                  A : separated list of directories, each directory
                  is a directory of modules that replace upgradeable
                  modules in the runtime image
    --add-modules <module name>[,<module name>...]
                  root modules to resolve in addition to the initial module.
                  <module name> can also be ALL-DEFAULT, ALL-SYSTEM,
                  ALL-MODULE-PATH.
    --list-modules
                  list observable modules and exit
    -d <module name>
    --describe-module <module name>
                  describe a module and exit
    --dry-run     create VM and load main class but do not execute main method.
                  The --dry-run option may be useful for validating the
                  command-line options such as the module system configuration.
    --validate-modules
                  validate all modules and exit
                  The --validate-modules option may be useful for finding
                  conflicts and other errors with modules on the module path.
    -D<name>=<value>
                  set a system property
    -verbose:[class|module|gc|jni]
                  enable verbose output
    -version      print product version to the error stream and exit
    --version     print product version to the output stream and exit
    -showversion  print product version to the error stream and continue
    --show-version
                  print product version to the output stream and continue
    --show-module-resolution
                  show module resolution output during startup
    -? -h -help
                  print this help message to the error stream
    --help        print this help message to the output stream
    -X            print help on extra options to the error stream
    --help-extra  print help on extra options to the output stream
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:jdwp
                  see also -agentlib:jdwp=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
                  show splash screen with specified image
                  HiDPI scaled images are automatically supported and used
                  if available. The unscaled image filename, e.g. image.ext,
                  should always be passed as the argument to the -splash option.
                  The most appropriate scaled image provided will be picked up
                  automatically.
                  See the SplashScreen API documentation for more information
    @argument files
                  one or more argument files containing options
    -disable-@files
                  prevent further argument file expansion
To specify an argument for a long option, you can use --<name>=<value> or
--<name> <value>.

sebastian@sebastian-virtual-machine:~$ java
Usage: java [options] <mainclass> [args...]
           (to execute a class)
   or  java [options] -jar <jarfile> [args...]
           (to execute a jar file)
   or  java [options] -m <module>[/<mainclass>] [args...]
       java [options] --module <module>[/<mainclass>] [args...]
           (to execute the main class in a module)

 Arguments following the main class, -jar <jarfile>, -m or --module
 <module>/<mainclass> are passed as the arguments to main class.

 where options include:

    -zero     to select the "zero" VM
    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    --class-path <class search path of directories and zip/jar files>
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -p <module path>
    --module-path <module path>...
                  A : separated list of directories, each directory
                  is a directory of modules.
    --upgrade-module-path <module path>...
                  A : separated list of directories, each directory
                  is a directory of modules that replace upgradeable
                  modules in the runtime image
    --add-modules <module name>[,<module name>...]
                  root modules to resolve in addition to the initial module.
                  <module name> can also be ALL-DEFAULT, ALL-SYSTEM,
                  ALL-MODULE-PATH.
    --list-modules
                  list observable modules and exit
    -d <module name>
    --describe-module <module name>
                  describe a module and exit
    --dry-run     create VM and load main class but do not execute main method.
                  The --dry-run option may be useful for validating the
                  command-line options such as the module system configuration.
    --validate-modules
                  validate all modules and exit
                  The --validate-modules option may be useful for finding
                  conflicts and other errors with modules on the module path.
    -D<name>=<value>
                  set a system property
    -verbose:[class|module|gc|jni]
                  enable verbose output
    -version      print product version to the error stream and exit
    --version     print product version to the output stream and exit
    -showversion  print product version to the error stream and continue
    --show-version
                  print product version to the output stream and continue
    --show-module-resolution
                  show module resolution output during startup
    -? -h -help
                  print this help message to the error stream
    --help        print this help message to the output stream
    -X            print help on extra options to the error stream
    --help-extra  print help on extra options to the output stream
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:jdwp
                  see also -agentlib:jdwp=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
                  show splash screen with specified image
                  HiDPI scaled images are automatically supported and used
                  if available. The unscaled image filename, e.g. image.ext,
                  should always be passed as the argument to the -splash option.
                  The most appropriate scaled image provided will be picked up
                  automatically.
                  See the SplashScreen API documentation for more information
    @argument files
                  one or more argument files containing options
    -disable-@files
                  prevent further argument file expansion
To specify an argument for a long option, you can use --<name>=<value> or
--<name> <value>.

sebastian@sebastian-virtual-machine:~$ 

@StephenC感谢您的帮助,如果我运行“sudo ant”它就能工作,但如果我用用户运行它,它会打印出“java -h”。

有没有办法解决这个问题?

请参阅终端日志:

sebastian@sebastian-virtual-machine:/usr/share/ant/bin$ sudo ant
Buildfile: build.xml does not exist!
Build failed
sebastian@sebastian-virtual-machine:/usr/share/ant/bin$ sudo ant -version
Apache Ant(TM) version 1.10.3 compiled on March 29 2018
sebastian@sebastian-virtual-machine:/usr/share/ant/bin$ ant -version
Usage: java [options] <mainclass> [args...]
           (to execute a class)
   or  java [options] -jar <jarfile> [args...]
           (to execute a jar file)
   or  java [options] -m <module>[/<mainclass>] [args...]
       java [options] --module <module>[/<mainclass>] [args...]
           (to execute the main class in a module)

 Arguments following the main class, -jar <jarfile>, -m or --module
 <module>/<mainclass> are passed as the arguments to main class.

 where options include:

    -zero     to select the "zero" VM
    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    --class-path <class search path of directories and zip/jar files>
                  A : separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -p <module path>
    --module-path <module path>...
                  A : separated list of directories, each directory
                  is a directory of modules.
    --upgrade-module-path <module path>...
                  A : separated list of directories, each directory
                  is a directory of modules that replace upgradeable
                  modules in the runtime image
    --add-modules <module name>[,<module name>...]
                  root modules to resolve in addition to the initial module.
                  <module name> can also be ALL-DEFAULT, ALL-SYSTEM,
                  ALL-MODULE-PATH.
    --list-modules
                  list observable modules and exit
    -d <module name>
    --describe-module <module name>
                  describe a module and exit
    --dry-run     create VM and load main class but do not execute main method.
                  The --dry-run option may be useful for validating the
                  command-line options such as the module system configuration.
    --validate-modules
                  validate all modules and exit
                  The --validate-modules option may be useful for finding
                  conflicts and other errors with modules on the module path.
    -D<name>=<value>
                  set a system property
    -verbose:[class|module|gc|jni]
                  enable verbose output
    -version      print product version to the error stream and exit
    --version     print product version to the output stream and exit
    -showversion  print product version to the error stream and continue
    --show-version
                  print product version to the output stream and continue
    --show-module-resolution
                  show module resolution output during startup
    -? -h -help
                  print this help message to the error stream
    --help        print this help message to the output stream
    -X            print help on extra options to the error stream
    --help-extra  print help on extra options to the output stream
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions with specified granularity
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions with specified granularity
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:jdwp
                  see also -agentlib:jdwp=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument
    -splash:<imagepath>
                  show splash screen with specified image
                  HiDPI scaled images are automatically supported and used
                  if available. The unscaled image filename, e.g. image.ext,
                  should always be passed as the argument to the -splash option.
                  The most appropriate scaled image provided will be picked up
                  automatically.
                  See the SplashScreen API documentation for more information
    @argument files
                  one or more argument files containing options
    -disable-@files
                  prevent further argument file expansion
To specify an argument for a long option, you can use --<name>=<value> or
--<name> <value>.

sebastian@sebastian-virtual-machine:/usr/share/ant/bin$ 

共有2个答案

马新觉
2023-03-14

检查以查看Ant的build.xml中是否有运行或链接到java命令的默认任务。

有时,此默认任务会尝试在环境或磁盘上查找内容,以“配置”潜在的 java 命令。

例如,呼叫

java ${something}

减少到

java

${something} 评估为 “” 时。

如果此 Ant 文件已被移动,则通常找不到配置,并且 java 命令将作为裸 java 调用启动,从而调用帮助输出。

谷梁宁
2023-03-14

证据是/usr/bin/ant以某种方式与javacommand链接、符号链接或别名。

在Linux,ant命令是一个外壳脚本,而(real)java命令是一个本机代码可执行文件。所以尝试以下操作:

$ type ant
$ file `which ant`

如果它显示为 ELF 二进制文件,请使用 Linux 命令将可执行文件与 Java 可执行文件进行比较。

如果它显示为shell脚本,您应该首先< code>less它,以查看它是否是正确的脚本。然后,您可以调整脚本(例如,通过临时添加< code>set -x)来查看当您运行< code>ant -version时它实际上在做什么。

类型ant还应该告诉您ant是shell函数还是别名。

但归根结底,您的系统或shell环境中的某些东西有点糟糕。

 类似资料:
  • curl-i-x post-f“imageFile=./image.jpg”http://myserver.com:8080/admin/02d0828864100000000b28c545b728f4/icon/add-v POST/ADMIN/02D0828864100000000B28C545B728F4/ICON/ADD HTTP/1.1用户代理:curl/7.30.0主机:MyServe

  • 本文向大家介绍Mysql help命令(帮助信息)中文注解,包括了Mysql help命令(帮助信息)中文注解的使用技巧和注意事项,需要的朋友参考一下 在开发或测试环境在碰到mysql相关故障时,大多数朋友可能会通过论坛发帖,QQ群讨论方式来获取帮助。该方式是获取帮助的有效途径之一。然而如果在生产环境,在没有网络的环境下,这些方式就无助于问题的解决。无论何种数据库,从官方网站获取帮助是最直接最有效

  • 1.1. 概述 在linux终端,面对命令不知道怎幺用,或不记得命令的拼写及参数时,我们需要求助于系统的帮助文档;linux系统内置的帮助文档很详细,通常能解决我们的问题,我们需要掌握如何正确的去使用它们; 在只记得部分命令关键字的场合,我们可通过man -k来搜索; 需要知道某个命令的简要说明,可以使用whatis;而更详细的介绍,则可用info命令; 查看命令在哪个位置,我们需要使用which

  • 使用help命令可以得到gdb的命令帮助信息: (1)help命令不加任何参数会得到命令的分类: (gdb) help List of classes of commands: aliases -- Aliases of other commands breakpoints -- Making program stop at certain points data -- Examining da

  • 本文向大家介绍深入理解mysql帮助命令(help),包括了深入理解mysql帮助命令(help)的使用技巧和注意事项,需要的朋友参考一下 在安装、管理和使用mysql过程中,你是不是需要记忆很多的mysql命令。而且对于新手来说,很不多的命令不知道该如何应用,对于老手来说很多命令时间长了忘记具体的用法。 其实mysql的帮助信息,已经给我们提供很全面的使用方法。 下面我就大致介绍下,如何使用my

  • 本文向大家介绍Linux shell命令帮助格式详解,包括了Linux shell命令帮助格式详解的使用技巧和注意事项,需要的朋友参考一下 前言 linux shell命令通常可以通过-h或--help来打印帮助说明,或者通过man命令来查看帮助,有时候我们也会给自己的程序写简单的帮助说明,其实帮助说明格式是有规律可循的 帮助示例 下面是git reset命令的帮助说明,通过man git-res