javac:无效标志:编译java servlet时出现.getting错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22317485/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
javac: invalid flag: .getting error when compiling a java servlet
提问by Ritesh Mehandiratta
i run command
我运行命令
javac -classpath /home/coolhunk/JBoss/jboss-6.0.0.Final/common/lib/jboss-servlet-api_3.0_spec.jar -d helloapp.war/WEB-INF/classes -sourcepath src/com/manning/jbia/intro/*
for generating java class files.but i am getting error
用于生成 java 类文件。但我收到错误
javac: invalid flag: src/com/manning/jbia/intro/HelloWorldServlet.java~
Usage: javac <options> <source files>
use -help for a list of possible options
can anyone please point out what is the mistake in this command ??
谁能指出这个命令的错误是什么??
回答by Balayesu Chilakalapudi
Try these commands using tomcat, place your servlet source in src folder and run these,
使用 tomcat 尝试这些命令,将您的 servlet 源放在 src 文件夹中并运行这些,
C:\Documents and Settings\ssit>cd C:\src
C:\src>javac -classpath "C:\Program Files\Apache Software Foundation\Tomcat 6.0\
lib\servlet-api.jar" MyServlet.java
you can get the class file for the servlet. After getting the class file make the war file.
您可以获取 servlet 的类文件。获得类文件后制作war文件。
回答by user207421
javac -classpath /home/coolhunk/JBoss/jboss-6.0.0.Final/common/lib/jboss-servlet-api_3.0_spec.jar -d helloapp.war/WEB-INF/classes -sourcepath src/com/manning/jbia/intro/*
The problem is the last item. The wildcard causes it to be expanded into everything in the directory, which causes everything after the first expansion to be treated as a source file name. The expansions also appear to include src/com/manning/jbia/intro/HelloWorldServlet.java~, which the compiler doesn't want to know about.
问题是最后一项。通配符使其扩展为目录中的所有内容,这导致第一次扩展后的所有内容都被视为源文件名。扩展似乎还包括编译器不想知道的 src/com/manning/jbia/intro/HelloWorldServlet.java~。
Try this:
尝试这个:
javac -classpath /home/coolhunk/JBoss/jboss-6.0.0.Final/common/lib/jboss-servlet-api_3.0_spec.jar -d helloapp.war/WEB-INF/classes -sourcepath src src/com/manning/jbia/intro/*.java