中的类创建jar。
当我尝试运行antbuild时,我在控制台中得到这些错误。请帮我解决这些错误。我还在Weblib..中包含了所有需要的jar ..
Buildfile: J:workspacenewbluemixxWordGuessbuild.xml
clean:
[delete] Deleting directory J:workspacenewbluemixxWordGuessbin
init:
[mkdir] Created dir: J:workspacenewbluemixxWordGuessbin
build-project:
[echo] WebStarterApp: J:workspacenewbluemixxWordGuessbuild.xml
[javac] Compiling 7 source files to J:workspacenewbluemixxWordGuessbin
[javac] J:workspacenewbluemixxWordGuesssrccombluemixhangmandataCloudantConnection.java:7: error: package org.apache.wink.json4j does not exist
[javac] import org.apache.wink.json4j.JSONArray;
[javac] ^
[javac] J:workspacenewbluemixxWordGuesssrccombluemixhangmandataCloudantConnection.java:8: error: package org.apache.wink.json4j does not exist
[javac] import org.apache.wink.json4j.JSONObject;
[javac] ^
[javac] J:workspacenewbluemixxWordGuesssrccombluemixhangmanmodelCategory.java:18: error: package com.fasterxml.jackson.annotation does not exist
[javac] import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
[javac] ^
[javac] J:workspacenewbluemixxWordGuesssrccombluemixhangmanmodelCategory.java:19: error: package com.fasterxml.jackson.annotation does not exist
[javac] import com.fasterxml.jackson.annotation.JsonProperty;
[javac] ^
[javac] J:workspacenewbluemixxWordGuesssrccombluemixhangmanmodelCategory.java:21: error: cannot find symbol
[javac] @JsonIgnoreProperties({"id", "revision"})
[javac] ^
[javac] symbol: class JsonIgnoreProperties
[javac] J:workspacenewbluemixxWordGuesssrccombluemixhangmanmodelWord.java:18: error: package com.fasterxml.jackson.annotation does not exist
[javac] import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
[javac] ^
[javac] J:workspacenewbluemixxWordGuesssrccombluemixhangmanmodelWord.java:19: error: package com.fasterxml.jackson.annotation does not exist
[javac] import com.fasterxml.jackson.annotation.JsonProperty;
[javac] ^
[javac] J:workspacenewbluemixxWordGuesssrccombluemixhangmanmodelWord.java:21: error: cannot find symbol
[javac] @JsonIgnoreProperties({"id", "revision"})
[javac] ^
[javac] symbol: class JsonIgnoreProperties
[javac] J:workspacenewbluemixxWordGuesssrccombluemixhangmanmodelCategory.java:24: error: cannot find symbol
[javac] @JsonProperty("_id")
[javac] ^
[javac] symbol: class JsonProperty
[javac] location: class Category
[javac] J:workspacenewbluemixxWordGuesssrccombluemixhangmanmodelCategory.java:27: error: cannot find symbol
[javac] @JsonProperty("_rev")
[javac] ^
[javac] symbol: class JsonProperty
[javac] location: class Category
[javac] J:workspacenewbluemixxWordGuesssrccombluemixhangmanmodelWord.java:24: error: cannot find symbol
[javac] @JsonProperty("_id")
[javac] ^
[javac] symbol: class JsonProperty
[javac] location: class Word
[javac] J:workspacenewbluemixxWordGuesssrccombluemixhangmanmodelWord.java:27: error: cannot find symbol
[javac] @JsonProperty("_rev")
[javac] ^
[javac] symbol: class JsonProperty
[javac] location: class Word
[javac] J:workspacenewbluemixxWordGuesssrccombluemixhangmandataCloudantConnection.java:27: error: cannot find symbol
[javac] JSONObject obj = new JSONObject(System.getenv("VCAP_SERVICES"));
[javac] ^
[javac] symbol: class JSONObject
[javac] location: class CloudantConnection
[javac] J:workspacenewbluemixxWordGuesssrccombluemixhangmandataCloudantConnection.java:27: error: cannot find symbol
[javac] JSONObject obj = new JSONObject(System.getenv("VCAP_SERVICES"));
[javac] ^
[javac] symbol: class JSONObject
[javac] location: class CloudantConnection
[javac] J:workspacenewbluemixxWordGuesssrccombluemixhangmandataCloudantConnection.java:28: error: cannot find symbol
[javac] String[] names = JSONObject.getNames(obj);
[javac] ^
[javac] symbol: variable JSONObject
[javac] location: class CloudantConnection
[javac] J:workspacenewbluemixxWordGuesssrccombluemixhangmandataCloudantConnection.java:33: error: cannot find symbol
[javac] JSONArray val = obj.getJSONArray(name);
[javac] ^
[javac] symbol: class JSONArray
[javac] location: class CloudantConnection
[javac] J:workspacenewbluemixxWordGuesssrccombluemixhangmandataCloudantConnection.java:34: error: cannot find symbol
[javac] JSONObject serviceAttr = val.getJSONObject(0);
[javac] ^
[javac] symbol: class JSONObject
[javac] location: class CloudantConnection
[javac] J:workspacenewbluemixxWordGuesssrccombluemixhangmandataCloudantConnection.java:35: error: cannot find symbol
[javac] JSONObject credentials = serviceAttr.getJSONObject("credentials");
[javac] ^
[javac] symbol: class JSONObject
[javac] location: class CloudantConnection
[javac] 18 errors
BUILD FAILED
J:workspacenewbluemixxWordGuessbuild.xml:30: Compile failed; see the compiler error output for details.
Total time: 539 milliseconds
当我尝试运行antbuild时,我在控制台中得到这些错误。请帮我解决这些错误。我还在Weblib中包含了所有需要的jar ..
请确保通过ant正确编译类,同时准备jar/war…确保指定basedir作为包含所有类的目录,ant将Java源代码编译为类的目录是同一个目录。
下面是一个简单的例子
'
<target name="clean">
<delete dir="build"/>
</target>
<target name="compile">
<mkdir dir="build/classes"/>
<javac srcdir="src" destdir="build/classes"/>
</target>
<target name="jar">
<mkdir dir="build/jar"/>
<jar destfile="build/jar/HelloWorld.jar" basedir="build/classes">
<manifest>
<attribute name="Main-Class" value="oata.HelloWorld"/>
</manifest>
</jar>
</target>
<target name="run">
<java jar="build/jar/HelloWorld.jar" fork="true"/>
</target>
`在这里,您可以看到compile目标将java代码编译到build/classes中,而jar目标从build/classes目录