简体   繁体   English

apache ant 无法找到或加载主类 org.apache.tools.ant.launch.Launcher

[英]apache ant Could not find or load main class org.apache.tools.ant.launch.Launcher

I'm trying to compile a tool which uses apache ant on linux我正在尝试编译一个在 linux 上使用 apache ant 的工具

https://github.com/lindenb/jvarkit https://github.com/lindenb/jvarkit

When I tried to compile the tool , I get n error.当我尝试编译该工具时,出现 n 错误。

$ make vcffilterjs

this is what I get when I'm running the command这是我运行命令时得到的

echo "Compiling htsjdk with ${JAVA_HOME} = /usr/lib/jvm/java/jre/"
Compiling htsjdk with /usr/lib/jvm/java/jre/ = /usr/lib/jvm/java/jre/
echo "Compiling htsjdk library for java. Requires  apache ANT. If it fails      here, it's a not a problem with jvarkit."
Compiling htsjdk library for java. Requires  apache ANT. If it fails here,  it's a not a problem with jvarkit.
echo "And ${JAVA_HOME}/bin/javac should be >=1.7"
And /usr/lib/jvm/java/jre//bin/javac should be >=1.7
(cd /home/jannahS/jvarkit/htsjdk-1.139 && ant )
Error: Could not find or load main class  org.apache.tools.ant.launch.Launcher
make: *** [/home/jannahS/jvarkit/htsjdk-1.139/dist/htsjdk-1.139.jar] Error 1

I have installed apache ant and tried to set ANT_HOME following google instruction我已经安装了 apache ant 并尝试按照谷歌指令设置 ANT_HOME

export ANT_HOME=apache-ant-1.9.6
ANT_OPTS="-Xms256M -Xmx512M"
PATH=$PATH:$HOME/bin:$ANT_HOME/bin
export ANT_HOME ANT_OPTS PAT

I also have set JAVA_HOME我也设置了JAVA_HOME

export JAVA_HOME=/usr/lib/jvm/jre-1.7.0
export PATH=$JAVA_HOME/jre/bin:$PATH

When I run当我跑

ant --execdebug蚂蚁 --execdebug

exec "/usr/lib/jvm/java/jre//bin/java" -Xmx256M -classpath "apache-ant-  1.9.6/lib/ant-launcher.jar" -Dant.home="apache-ant-1.9.6" -Dant.library.dir="apache-ant-1.9.6/lib" org.apache.tools.ant.launch.Launcher -cp ""
Buildfile: build.xml does not exist!
Build failed

I don't know what else to do to make things to work.我不知道还能做些什么来使事情发挥作用。 I can't compile the tool that I want to use without apache ant我无法在没有 apache ant 的情况下编译我想使用的工具

Use full path in ANT_HOME, eg:在 ANT_HOME 中使用完整路径,例如:

export ANT_HOME=/usr/lib/apache-ant-1.9.6

It dependes where it is exactly located这取决于它的确切位置

Could not find or load main class org.apache.tools.ant.launch.Launcher无法找到或加载主类org.apache.tools.ant.launch.Launcher

In mac this is due to some environment issue if you install the ant using brew command,在 mac 中,这是由于一些环境问题,如果您使用 brew 命令安装 ant,

copy the lib folder from the ant and paste it into the bin folder从ant复制lib文件夹并粘贴到bin文件夹中

now run the command issue is resolved:-)现在运行命令问题解决了:-)

issue reason问题原因

ant is trying to get the bin/lib/ant-launcher.jar file from the invalid path ant 试图从无效路径获取bin/lib/ant-launcher.jar文件

In Mac, after running brew install ant , I had to run brew link ant to fully link ant to system environment.在 Mac 中,运行brew install ant ,我必须运行brew link ant以将 ant 完全链接到系统环境。

Running brew link --verbose --overwrite ant I get:运行brew link --verbose --overwrite ant我得到:

Linking /usr/local/Cellar/ant/1.10.5... 
ln -s ../Cellar/ant/1.10.5/bin/ant ant
ln -s ../Cellar/ant/1.10.5/bin/antRun antRun
ln -s ../Cellar/ant/1.10.5/bin/antRun.pl antRun.pl
ln -s ../Cellar/ant/1.10.5/bin/complete-ant-cmd.pl complete-ant-cmd.pl
ln -s ../Cellar/ant/1.10.5/bin/runant.pl runant.pl
ln -s ../Cellar/ant/1.10.5/bin/runant.py runant.py
6 symlinks created

And when running "ant" with no params from command-line:当从命令行运行没有参数的“ant”时:

Buildfile: build.xml does not exist!
Build failed

Which is what I expect if testing outside the context of an existing ant project.如果在现有 ant 项目的上下文之外进行测试,这就是我所期望的。

  1. Run "which ant" >> to know if the ant_home set.运行“which ant” >> 以了解 ant_home 是否设置。 If not please run below with your corresponding paths to set ant_home如果没有,请在下面运行您的相应路径来设置 ant_home

export ANT_HOME =/ade_autofs/gd29_3rdparty/ANT_1.7.1_GENERIC.rdd/080925/ant export PATH=/ade_autofs/gd29_3rdparty/ANT_1.7.1_GENERIC.rdd/080925/ant:${PATH}导出 ANT_HOME =/ade_autofs/gd29_3rdparty/ANT_1.7.1_GENERIC.rdd/080925/ant 导出路径=/ade_autofs/gd29_3rdparty/ANT_1.7.1_GENERIC.rdd/080925/ant:${PATH}

Try ant build.尝试蚂蚁构建。 It should work without any error.它应该可以正常工作而不会出现任何错误。

"I agreed with full path issue for the above issue, getting the same exception while folder has access problem" “我同意上述问题的完整路径问题,当文件夹有访问问题时得到相同的异常”

I have faced the same exception in Macbook.我在 Macbook 中也遇到过同样的异常。 Checked all the configurations JAVA_HOME, ANT_HOME and org.apache.tools.ant.launch.Launcher file in Ant related jars.检查了 Ant 相关 jars 中的所有配置 JAVA_HOME、ANT_HOME 和 org.apache.tools.ant.launch.Launcher 文件。 Finally, found the issue, due to an access problem of the apache-ant folder.终于找到问题了,是apache-ant文件夹的访问问题。 I have no admin access, so I moved my setup to the desktop.我没有管理员访问权限,所以我将设置移到桌面。


$ make vcffilterjs : Compiles OK, with any of these "Linux OS´s" : $ make vcffilterjs :使用这些“Linux 操作系统”中的任何一个都可以编译:

Debian 8 Jessie, CentOS 7, Fedora 23, Ubuntu 15.10, PCLinuxOS 2015. Debian 8 Jessie、CentOS 7、Fedora 23、Ubuntu 15.10、PCLinuxOS 2015。

No "ANT_HOME" or "JAVA_HOME" settings required, by using the default installed 'ant' and openjdk.不需要“ANT_HOME”或“JAVA_HOME”设置,使用默认安装的“ant”和openjdk。

? ? Which "Linux OS" are you using ?您使用的是哪个“Linux 操作系统”?


暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到或加载主类org.apache.tools.ant.launch.launcher - Could not find or load main class org.apache.tools.ant.launch.launcher Ant失败:线程“main”中的异常java.lang.NoClassDefFoundError org / apache / tools / ant / launch / Launcher - Ant failure: Exception in thread “main” java.lang.NoClassDefFoundError org/apache/tools/ant/launch/Launcher 错误:无法在 Java Spark 中找到或加载主类 org.apache.spark.launcher.Main - Error: Could not find or load main class org.apache.spark.launcher.Main in Java Spark Apache Ant:无法找到主类。 程序将会退出 - Apache Ant: Could not find the main class. Program will exit Apache Ant:在Windows 7命令提示符下找不到或加载主类集 - Apache Ant: Could not find or load main class set on Windows 7 command prompt 错误:无法在Hadoop上找到或加载主类org.apache.hadoop.hdfs.tools.GetConf - Error: Could not find or load main class org.apache.hadoop.hdfs.tools.GetConf on Hadoop 正在运行hadoop作业:找不到类-org.apache.tools.ant.launch.AntMain - Running hadoop job: Class not found - org.apache.tools.ant.launch.AntMain 尝试运行derby时在Eclipse上“找不到或加载主类org.apache.derby.tools.ij” - “Could not find or load main class org.apache.derby.tools.ij” on Eclipse when trying to run derby 蚂蚁罐找不到或加载主类 - Ant jar Could not find or load main class 为什么./sbin/start-master.sh给出“错误:找不到或加载主类org.apache.spark.launcher.Main”? - Why does ./sbin/start-master.sh give “Error: Could not find or load main class org.apache.spark.launcher.Main”?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM