当我尝试在服务器上运行我的小程序时,它似乎永远不会走出第一步,即加载库,当我尝试在 localhost 上运行时,它可以完美运行
代码
private final static String DEFAULT_DOWNLOAD_PATH = "http://colorfulwolf.com/dev/cam/";
private final static String VERSION_ID = "1.0.0";
// note that this list is windows-specific, so this is not a generic
// solution that works on all OSes
private final static String[] LIBS = { "cv210.dll", "cvaux210.dll",
"cxcore210.dll", "cxts210.dll", "highgui210.dll", "ml210.dll" };
private final static String LIB_ARCHIVE = "opencv21.zip";
public void loadWebcam() {
loadingScreen.setMaxProgress(7);
loadingScreen.setProgress(1, "Loading Librarys..");
String tmpDir = System.getProperty("java.io.tmpdir");
File faPath = new File(tmpDir + File.separator + "WebcamApplet_"
+ VERSION_ID.replaceAll("\\.", "-"));
System.out.println(faPath);
System.setProperty("jna.library.path", faPath.getAbsolutePath());
String downloadPath = this.getParameter("dll_path");
if (downloadPath == null)
downloadPath = DEFAULT_DOWNLOAD_PATH;
try {
prepareLibraries(faPath, downloadPath);
} catch (Exception e) {
e.printStackTrace();
loadingScreen.setProgress(3, "Erro: " + e.getMessage());
return;
}
}
private void prepareLibraries(File localPath, String downloadPath)
throws Exception {
if (localPath.exists()) {
boolean libMissing = false;
for (String lib : LIBS) {
File libFile = new File(localPath.getAbsolutePath()
+ File.separator + lib);
if (!libFile.exists()) {
libMissing = true;
break;
}
}
if (!libMissing)
return; // We don't have to download
}
if (!localPath.exists() && !localPath.mkdirs()) // Error fatal!
throw new Exception("Can't create the path: " + localPath);
loadingScreen.setProgress(2, "Downloading library...");
File file = new File(localPath.getAbsolutePath() + File.separator
+ LIB_ARCHIVE);
String link = downloadPath + LIB_ARCHIVE;
download(link, file);
ZipFile zipFile = new ZipFile(file);
Enumeration<? extends ZipEntry> entries = zipFile.entries();
loadingScreen.setProgress(3, "Installing librarys..");
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (entry.isDirectory())
continue;
File tar = new File(localPath.getAbsolutePath() + File.separator
+ entry.getName());
InputStream is = zipFile.getInputStream(entry);
OutputStream os = new FileOutputStream(tar);
copyStream(is, os);
os.flush();
os.close();
is.close();
}
zipFile.close();
file.delete();
if (file.exists())
file.deleteOnExit();
}
我将 jar 文件放在服务器上的可见HTTP
路径中
<applet code="com.colorfulwolf.webcamapplet.WebcamApplet"
archive="http://www.netimoveis.com/teste.jar, http://www.netimoveis.com/core.jar, http://www.netimoveis.com/javacv.jar, http://www.netimoveis.com/javase.jar, http://www.netimoveis.com/jna.jar, http://www.netimoveis.com/customizer.jar, http://www.netimoveis.com/jmf.jar, http://www.netimoveis.com/meidaplayer.jar, http://www.netimoveis.com/multiplayer.jar, http://www.netimoveis.com/sound.jar"
height="550" width="550">
</applet>
为什么当我尝试在服务器上运行小程序时,它没有离开第一步?
@更新
我找到了代码不会移动到下一行代码的行。
String tmpDir = System.getProperty("java.io.tmpdir");
这一行是我的代码停止的地方,仍然在这一行。Java 当前安装在服务器中。