我很喜歡Java的新手,並且在dotnet中有一些經驗。內容是用java(jdk 1.6)創建一個Web服務,並通過dotnet使用它。請假定我是Java的初學者。在Mustang中創建和發佈Web Service的問題(Java 1.6 sdk)
我得到了使用Java創建Web服務卡住了(我是新來的吧)..這是我的節目(樣品來自net拍攝)
package example;
import javax.jws.WebService;
import javax.jws.WebService;
import javax.xml.ws.Endpoint;
@WebService
public class Calculator {
@WebMethod(action="addNumbers")
public int Add(int number1, int number2) {
return number1 + number2;
}
}
public static void main(String[] args)
{
Calculator server = new Calculator();
Endpoint endpoint = Endpoint.publish("http://localhost:8080/AddWebService", server);
}
所以創建這個後,我保存爲計算器在名爲.java C:\ Program Files文件\的Java \ jdk1.6.0 \ BIN
然後開始我編譯爲
容易-d例如/ Calculator.java
然後
java命令example.Calculator
然後我試圖訪問的WSDL文件作爲http://localhost:8080/AddWebService?wsdl但沒有結果......能不能請你幫我爲自己做錯了什麼,我做..
編輯
後,我跑了容易
-d example/Calculator.java
我得到了下面的控制檯我跑
java -cp example.Calculator
warning: The apt tool and its associated API are planned to be
removed in the next major JDK release. These features have been
superseded by javac and the standardized annotation processing API,
javax.annotation.processing and javax.lang.model. Users are
recommended to migrate to the annotation processing features of
javac; see the javac man page for more information.
Usage: apt <apt and javac options> <source files>
where apt options include:
-classpath <path> Specify where to find user class files and annotati
on processor factories
-cp <path> Specify where to find user class files and annotati
on processor factories
-d <path> Specify where to place processor and javac generate
d class files
-s <path> Specify where to place processor generated source f
iles
-source <release> Provide source compatibility with specified release
-version Version information
-help Print a synopsis of standard options; use javac -he
lp for more options
-X Print a synopsis of nonstandard options
-J<flag> Pass <flag> directly to the runtime system
-A[key[=value]] Options to pass to annotation processors
-nocompile Do not compile source files to class files
-print Print out textual representation of specified types
-factorypath <path> Specify where to find annotation processor factorie
s
-factory <class> Name of AnnotationProcessorFactory to use; bypasses
default discovery process
See javac -help for information on javac options.
後,我recived以下控制檯
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See http://java.sun.com/javase/reference for more details.
我DONOT知道是不是預期的行爲或別的東西。
非常感謝
嗨,我連續運行這兩個a)apt -d示例/ Calculator.java b)java -cp。 example.Calculator我收到錯誤「錯誤:無法找到或加載主類example.Calculator」 – learner123