开发者

Importing org.apache.commons Java

I've been trying to import the apache commons inside my jar, but can't see to do it. This code below is the code I'm using:

import java.applet.Applet;
import org.apache.commons.io.*;


public class Java extends Applet
{
  public void init()
  {
    String str1 = "testing.html"
    String str2 = System.getProperty("java.io.tmpdir");
     try {
            URL url = new URL("http://www.facebook.com");
            File destination = new File(str2 + str1);
            FileUtils.copyURLToFile(url, destination);
        } catch (IOException e) {
            e.printStackTrace();
        }
}
}

I compiled it with the command prompt:

set /p c=Please choose a signature name: 
keytool.exe -genkey -keyalg rsa -alias %c%
keytool.exe -export -alias %c% -file Certificate.crt
javac.exe Java.java -cp commons.jar
jar.exe cvf开发者_运维知识库 Java.jar *.class commons.jar
jarsigner.exe Java.jar %c%

Finally we got my HTML code to run it:

<applet width='100px' height='200px' code='Java.class' archive="Java.jar, commons.jar">
</applet>

Now when I run it, it wont download the file and place it in the temp folder. Why is that?


You appear to be trying to place the commons.jar inside your other JAR file; that won't work. You need to place it on the webserver in the same directory as your other JAR file. The browser can't download a file that doesn't exist on the server, and no code on the server is going to unpack that JAR.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜