从Jar重新编译一个Java类 [英] Re-compile a Java Class from Jar
问题描述
我有一个可执行的jar有一个类文件的值错误。我请求作者的文件,并更正了值。
现在我想编译它,并将编译的类文件添加到jar并运行它。
毫不奇怪,我在jar文件中的自定义对象的引用获取了多个无法找到符号错误。
我试图通过引用类路径中的jar文件来编译文件,如
C:/> javac file.java -classpath C:/ folder / where / jar / is
工作...我得到相同的错误,如果只是做
C:/> javac file.java
有没有办法编译这个单独的类引用jar中的其他文件?
谢谢。
错误我得到了以下的一些建议:
javac -classpath C:/jar/location.jar File.java
File.java:226:找不到符号
symbol:class Stuff
location:class com.shared.stuffers
Stuff s1 = new Stuff();
^
在Jar中找到Stuff类,但javac程序无法看到...我感觉我做错了,但不知道在哪里?
您将需要编译您的文件:
javac -classpath C:\folder\where\jar\is\the_jar_file.jar file.java
$根据javac使用说明,p $ p>
C:\Console2> ; javac -help
用法:javac< options> <源文件>
I have an executable jar that has one class file with a wrong value. I requested that file from the author and corrected the value.
Now I want to compile it and add the compiled class file into the jar and run it.
Not surprisingly I get multiple "cannot find symbol" errors for references of custom object that were in the jar file.
I tried to compile the file by referencing the jar file in the classpath like so
C:/> javac file.java -classpath C:/folder/where/jar/isbut this doesnt seem to work... I get the same errors as if just doing
C:/> javac file.javaIs there a way to compile this individual class somehow referencing the other files in the jar?
Thanks.
Errors I am getting while following some of the suggestions below here:
javac -classpath C:/jar/location.jar File.java File.java:226: cannot find symbol symbol : class Stuff location: class com.shared.stuffers Stuff s1 = new Stuff(); ^Stuff class is found in the Jar, but can not be seen by the javac program... I feel like I am doing something wrong but not sure where? Thanks.
解决方案You will want to compile your file like so:
javac -classpath C:\folder\where\jar\is\the_jar_file.jar file.java
per the javac usage instructions:
C:\Console2>javac -help Usage: javac <options> <source files>
这篇关于从Jar重新编译一个Java类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!