Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java ANT-无法加载依赖类com/jcraft/jsch/Logger_Java_Ant_Classloader - Fatal编程技术网

Java ANT-无法加载依赖类com/jcraft/jsch/Logger

Java ANT-无法加载依赖类com/jcraft/jsch/Logger,java,ant,classloader,Java,Ant,Classloader,我的Ant脚本有问题 我需要将一个文件复制到Linux服务器 <copy file="../Ant/lib/jsch-0.1.50.jar" tofile="${ant.home}/lib/jsch-0.1.50.jar" /> <scp todir="${server.user}:${server.password}@${server.dev}:${server.dev.dir.config}" trust="true" verbose="true"> <

我的Ant脚本有问题

我需要将一个文件复制到Linux服务器

<copy file="../Ant/lib/jsch-0.1.50.jar" tofile="${ant.home}/lib/jsch-0.1.50.jar" />

<scp todir="${server.user}:${server.password}@${server.dev}:${server.dev.dir.config}" trust="true" verbose="true">
    <fileset dir="${src.home}/Config/">
        <include name="**/*" />
    </fileset>
</scp>


如何在Ant类加载器中动态添加此JAR?

使用类似的
将JSCH的所有依赖项添加到Ant的
lib
目录异常本身非常清楚,并指出了问题的原因:

Action: Determine what extra JAR files are needed, and place them in one of:
    -C:\Progs\eclipse\plugins\org.apache.ant_1.8.3.v201301120609\lib
    -C:\Users\Administrator\.ant\lib
    -a directory added on the command line with the -lib argument
请查收

jsch.jar 0.1.50或更高版本:sshexec和scp任务()

如果在ant库中复制此库,它将解决独立ant的问题


对于Eclipse:进入Eclipse首选项,在Ant/Runtime条目中的“Classpath”选项卡中。使用“添加外部jar”按钮将jsch.jar添加到Ant的类路径。

将jsch-0.1.51.jar复制到/usr/share/Ant/lib/(或任何目录)后,使jar文件对所有用户都可读,而不仅仅是根用户。不要像我一样,花半个小时试图找出它为什么不起作用。

我已经找到了解决方案

如果您使用Eclipse作为IDE,并且从Eclipse运行ant,则不足以复制所需的jar文件jsch-0.1.51.jar(或任何版本)。还需要在运行时更改ant使用的类路径

如果使用Windows->Window>Preferences>Ant>Runtime 如果使用Mac->Eclipse>Preferences>Ant>Runtime

在“Ant home entries…”的类路径选项卡中,必须添加新的jar

在那之后它就开始工作了

Action: Determine what extra JAR files are needed, and place them in one of:
    -C:\Progs\eclipse\plugins\org.apache.ant_1.8.3.v201301120609\lib
    -C:\Users\Administrator\.ant\lib
    -a directory added on the command line with the -lib argument