Java Ant构建无法运行mkdir
我目前正在尝试为一个不再为美国市场服务的旧版mmo购买一个专用服务器。我决不是一个Java天才,但我已经在谷歌上搜索了好几个小时,脑袋撞在墙上,一点运气都没有。为此,我使用eclipse,安装了JDK和JRE,并配置了路径 build.xml文件:Java Ant构建无法运行mkdir,java,xml,eclipse,ant,Java,Xml,Eclipse,Ant,我目前正在尝试为一个不再为美国市场服务的旧版mmo购买一个专用服务器。我决不是一个Java天才,但我已经在谷歌上搜索了好几个小时,脑袋撞在墙上,一点运气都没有。为此,我使用eclipse,安装了JDK和JRE,并配置了路径 build.xml文件: <?xml version="1.0" encoding="UTF-8"?> <project name="L1J" default="all" basedir="."> <description> Thi
<?xml version="1.0" encoding="UTF-8"?>
<project name="L1J" default="all" basedir=".">
<description>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/
</description>
<!-- Set Property -->
<property name="src.dir" value="src" />
<property name="lib.dir" value="libs" />
<property name="build.dir" value="build" />
<property name="main.class" value="jp.l1j.Server" />
<property name="jarfile" value="l1jserver.jar" />
<path id="libs">
<fileset dir="${lib.dir}" includes="*.jar"/>
</path>
<pathconvert property="classpath" refid="libs" targetos="windows" pathsep=" ">
<map from="${basedir}\${lib.dir}\" to="./${lib.dir}/"/>
<map from="\" to="/"/>
</pathconvert>
<!-- Set DefaultTarget -->
<target name="all" depends="clean,compile,jar,clean2" />
<!-- clean Target -->
<target name="clean">
<delete dir="${build.dir}" />
</target>
<!-- Compile Target -->
<target name="compile">
<mkdir dir="${build.dir}" />
<javac includeantruntime="true" srcdir="${src.dir}"
destdir="${build.dir}"
optimize="on"
debug="on"
encoding="UTF-8">
<classpath refid="libs" />
<compilerarg value="-Xlint:unchecked" />
</javac>
</target>
<!-- jar Target -->
<target name="jar">
<jar jarfile="${jarfile}" basedir="${build.dir}">
<manifest>
<attribute name="Main-Class" value="${main.class}" />
<attribute name="Class-Path" value="${classpath}" />
</manifest>
</jar>
</target>
<!-- clean Target -->
<target name="clean2">
<delete dir="${build.dir}" />
</target>
</project>
我确实尝试过手动创建目录,这样做允许脚本运行,但在使用此启动服务器批处理文件运行时,会出现“找不到或加载主类jp.l1j.server”错误:
@java -server -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=256m -Xms1024m -Xmx1024m -XX:NewRatio=2 -XX:SurvivorRatio=8 -jar l1jserver
@pause
任何帮助都将不胜感激 您不需要任何第三方库来编译或运行应用程序吗?
因为必须手动创建libs目录,所以类路径似乎总是空的。我假设您在构建jar时不需要任何依赖项,因为ant构建成功了,但是在运行时可能需要一些依赖项?嵌套在
路径中的文件集,id为libs,在执行pathconvert
任务时,该文件集正在扫描目录libs。由于pathconvert
在任何target
之外,因此它在任何target
之前执行
此外,对于lib.dir
,我没有看到任何mkdir
@java -server -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=256m -Xms1024m -Xmx1024m -XX:NewRatio=2 -XX:SurvivorRatio=8 -jar l1jserver
@pause