简体   繁体   中英

trying to compile a new servlet to do a rest service

I'm a noob at building a servlet for rest and these versions of tech.... Because of where the servlet has to run we are on Java 1.4.2_08 and Tomcat version 5.5.17 I've created a Hello World example and am trying to compile it. It uses the Jersey library(JAX-RS 2.1) and get the following error: "javac: no source files"

This the cmd I'm using: C:\\j2sdk1.4.2_08\\bin\\javac -sourcepath C:_restful\\WEB-INF\\classes\\com\\dmphealth\\ws\\helloworldresource.java -classpath "C:_restful\\WEB-INF\\lib\\" -d C:_restful\\WEB-INF\\classes I've tried using just a \\ after \\ws\\ and have also tried *.java and * after the \\ws\\ They all had the same result... Any thoughts would be greatly appreciated. Dave

To clarify the code is in italics above. The C:_restful is the first part of the path to where the libraries and code live. The reason for java 1.4 is because the system the servlet will go in is on that platform. To costly at this time to upgrade the platform for one additional servlet.

Your directory structure is strange. It is better not to store any sources in a classes directory.

The Tomcat classes directory usually contains the compiled classes (.class files) and not the sources (.java files). The source files should be in a development repository, and compiling them will actually create the .class files and copy them to WEB-INF\\classes

The command should be like this :

C:\\j2sdk1.4.2_08\\bin\\javac -sourcepath C:\\path_to_the_source_file_dir\\*.java -classpath C:\\_restful\\WEB-INF\\lib\\* -d C:\\_restful\\WEB-INF\\classes

Make sure that the -sourcepath actually contains any .java file to be compiled!

The way you do this is not going to be easy. It would be much better for you to use an IDE, create a lib class path then from there compile your code and redirect the compile output to your target class directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM