2016-02-12 133 views
0

我目前正在試圖獲得一個私人服務器的老年人不再服務美國去。我絕不是一個Java高手,但我一直在Google上搜索,並且在沒有運氣的情況下在牆上敲了幾個小時。我爲此使用了eclipse,安裝了JDK和JRE並配置了路徑。螞蟻生成未能mkdir

build.xml文件:

<?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> 

從Eclipse中的輸出運行中的build.xml後:

Buildfile: C:\Users\Administrator\workspace\L1J\build.xml 

BUILD FAILED 
C:\Users\Administrator\workspace\L1J\build.xml:28: C:\Users\Administrator\workspace\L1J\libs does not exist. 

Total time: 390 milliseconds 

我也嘗試手動創建目錄,這樣做允許腳本運行,但是當它與這個啓動服務器批處理文件一起運行時,這給了我一個「無法找到或加載主類jp.l1j.server」的錯誤:

@java -server -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=256m -Xms1024m -Xmx1024m -XX:NewRatio=2 -XX:SurvivorRatio=8 -jar l1jserver 
@pause 

任何幫助將不勝感激!

回答

0

您是否需要任何第三方庫來編譯或運行您的應用程序? 看來你的類路徑總是空的,因爲你必須手動創建libs目錄。我認爲在構建你的jar時你不需要任何依賴,因爲ant構建成功了,但是在運行時可能需要一些嗎?

0

使用id libs嵌套在path中的fileset正在執行pathconvert任務時正在掃描目錄庫。由於pathconvert不在target以外,因此在任何target之前執行。

另外,無論如何我沒有看到mkdirlib.dir