मेरा मुख्य():जावा - पकड़ने System.load() त्रुटियाँ
System.out.println("Start loading libraries");
boolean b2 = false;
try{
b2 = FileManager.loadBinaries();
} catch (Exception e){
System.out.println("Exception on loading");
}
System.out.println("Libraries loading ended");
LoadBinaries():
Start loading libraries
Hello Load
Bye Load
Hello Load
Bye Load
Hello Load
Bye Load
Hello Load
Bye Load
Hello Load
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\java\workspace\Lib\mylib.dll: The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log for more detail
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at nm.player.FileManager.loadBinaries(FileManager.java:264)
at nm.player.Player.<init>(Player.java:88)
at nm.player.Player.main(Player.java:523)
:
public static boolean loadBinaries(){
String os = System.getProperty("os.name").toLowerCase();
ArrayList<String> bins = new ArrayList<String>();
if(os.indexOf("windows 7") >= 0 || os.indexOf("windows vista") >= 0){
bins.add("/nm/metadata/bin/win/libcurld.dll");
bins.add("/nm/metadata/bin/win/libfftw3f-3.dll");
bins.add("/nm/metadata/bin/win/libmad.dll");
bins.add("/nm/metadata/bin/win/libsamplerate.dll");
bins.add("/nm/metadata/bin/win/seven/mylib.dll");
}
else if(os.indexOf("windows xp") >= 0){
bins.add("/nm/metadata/bin/win/libcurld.dll");
bins.add("/nm/metadata/bin/win/libfftw3f-3.dll");
bins.add("/nm/metadata/bin/win/libmad.dll");
bins.add("/nm/metadata/bin/win/libsamplerate.dll");
bins.add("/nm/metadata/bin/win/xp/mylib.dll");
} else if(os.indexOf("mac") >= 0){
return false;
}
File f = null;
for(String bin : bins){
InputStream in = FileManager.class.getResourceAsStream(bin);
byte[] buffer = new byte[1024];
int read = -1;
try {
String[] temp = bin.split("/");
f = new File(LIB_FOLDER + "/" + temp[temp.length-1]);
File realF = new File(f.getAbsolutePath());
if(!realF.exists()){
FileOutputStream fos = new FileOutputStream(realF);
while((read = in.read(buffer)) != -1) {
fos.write(buffer, 0, read);
}
fos.close();
in.close();
}
System.out.println("Hello Load");
System.load(f.getAbsolutePath());
System.out.println("Bye Load");
} catch (Exception e) { System.out.println("Bye Exception"); FileManager.log(e.getMessage(), true); librariesLoaded = false; return false; }
}
System.out.println("Bye Method");
librariesLoaded = true;
return true;
}
जब मैं इस मुख्य चलाने मैं अगले आउटपुट प्राप्त
यह त्रुटि है क्योंकि यह कुछ C++ सिस्टम dlls गायब है। लेकिन मेरी समस्या यह नहीं है। इस चिंता के बाद कार्यक्रम कहां जाता है इस बारे में मुझे चिंता है! मुझे कैच पर प्रिंट नहीं दिखता है, विधि में लूप के बाद प्रिंट और न तो मुख्य पर प्रिंट, लोडबिनरी निष्पादित होने के बाद।
मैं इस प्रकार की त्रुटियों को कैसे पकड़ सकता हूं और उनसे निपट सकता हूं? उदाहरण: जब यह त्रुटि होती है, तो मैं "कृपया C++ लाइब्रेरी को इंटेल करें" प्रिंट करना चाहता हूं और उसके बाद प्रवाह को नियंत्रित करना चाहता हूं।
हालांकि यह एक अच्छा सामान्य नियम है कि 'त्रुटि' या उसके उप-वर्गों को पकड़ने के लिए नहीं, यह मामला अपवाद प्रतीत होता है। –