मुझे लगता है कि यह बहुत कठिन अपने आप के लिए एक उपकरण लिखने के लिए नहीं होगा।
आप System.getProperty ("java.class.path") के साथ क्लासपाथ प्रविष्टियां प्राप्त कर सकते हैं;
और फिर वहां सूचीबद्ध जार, ज़िप या निर्देशिकाओं के माध्यम से चलें और कक्षाओं के बारे में सारी जानकारी एकत्र करें और उन लोगों को ढूंढें जो परेशानी पैदा कर सकते हैं।
इस कार्य में सबसे अधिक 1 या 2 दिन लगेंगे। फिर आप इस कक्षा को सीधे अपने आवेदन में लोड कर सकते हैं और एक रिपोर्ट तैयार कर सकते हैं।
संभवतः java.class.path प्रॉपर्टी सभी कक्षाओं को दिखाती है यदि आप जटिल कस्टम क्लास लोडिंग के साथ कुछ बुनियादी ढांचे में भाग लेते हैं (उदाहरण के लिए मैंने एक बार एक ऐप देखा जो एलडीएपी से कक्षाएं लोड करता है) लेकिन यह निश्चित रूप से सबसे अधिक काम करेगा मामलों में से।
एक उपकरण है जो आपको उपयोगी लगेगा, मैंने इसे कभी भी अपने स्वयं का उपयोग नहीं किया है, लेकिन इसे आज़माएं और हमें परिणाम बताएं।
http://www.jgoodies.com/freeware/jpathreport/features.html
आप अपने खुद के उपकरण बनाने के लिए जा रहे हैं, यहाँ कोड मैं एक ही खोल स्क्रिप्ट से पहले पोस्ट के लिए उपयोग है, लेकिन है कि मैं अपने Windows मशीन पर इस्तेमाल करते हैं। जब कई जार फाइलें होती हैं तो यह तेजी से चलती है।
आप इसका उपयोग कर सकते हैं और इसे संशोधित कर सकते हैं ताकि एक निर्देशिका को फिर से चलने के बजाय, कक्षा पथ पढ़ें और क्लास टाइम विशेषता की तुलना करें।
वहाँ एक आदेश वर्ग आप उपवर्ग यदि आवश्यक हो तो, मैं की -execute विकल्प में सोच रहा था कर सकते हैं "लगता है"
यह मेरा खुद का कोड, बस करने के लिए है, तो यह "उत्पादन के लिए तैयार" करने का इरादा नहीं था काम करो।
import java.io.*;
import java.util.zip.*;
public class ListZipContent{
public static void main(String [] args) throws IOException {
System.out.println("start " + new java.util.Date());
String pattern = args.length == 1 ? args[0] : "OracleDriver.class";// Guess which class I was looking for :)
File file = new File(".");
FileFilter fileFilter = new FileFilter(){
public boolean accept(File file){
return file.isDirectory() || file.getName().endsWith("jar");
}
};
Command command = new Command(pattern);
executeRecursively(command, file, fileFilter);
System.out.println("finish " + new java.util.Date());
}
private static void executeRecursively(Command command, File dir , FileFilter filter) throws IOException {
if(!dir.isDirectory()){
System.out.println("not a directory " + dir);
return;
}
for(File file : dir.listFiles(filter)){
if(file.isDirectory()){
executeRecursively(command,file , filter);
}else{
command.executeOn(file);
}
}
}
}
class Command {
private String pattern;
public Command(String pattern){
this.pattern = pattern;
}
public void executeOn(File file) throws IOException {
if(pattern == null) {
System.out.println("Pattern is null ");
return;
}
String fileName = file.getName();
boolean jarNameAlreadyPrinted = false;
ZipInputStream zis = null;
try{
zis = new ZipInputStream(new FileInputStream(file));
ZipEntry ze;
while((ze = zis.getNextEntry()) != null) {
if(ze.getName().endsWith(pattern)){
if(!jarNameAlreadyPrinted){
System.out.println("Contents of: " + file.getCanonicalPath() );
jarNameAlreadyPrinted = true;
}
System.out.println(" " + ze.getName());
}
zis.closeEntry();
}
}finally{
if(zis != null) try {
zis.close();
}catch(Throwable t){}
}
}
}
मुझे उम्मीद है कि इससे मदद मिलती है।
जारफिश भी कोशिश करें (मेरा दूसरा जवाब); मैंने इसे सफलतापूर्वक –
यूप का उपयोग किया! या तो यह या http://stackoverflow.com/questions/135971/is-there-a-tool-to-discover-if-the-same-class-exists-in-multiple-jars-in-the-clas/4516827 # 4516827 चाल चलाना चाहिए! –
क्या कोई उपकरण/तरीका है जो केवल उपयोग (आयातित) कक्षाओं को फ़िल्टर करता है? हमारे पास हमारे क्लासपाथ में बहुत से डुप्लिकेट कक्षाएं हैं जिनका वास्तव में उपयोग नहीं किया जाता है –