-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finally moved up to 1.15. Also added 3137337 JNLP Example
- Loading branch information
clay_shooter
committed
Oct 1, 2011
1 parent
cd963dd
commit ede7d21
Showing
7 changed files
with
200 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<html> | ||
<head> | ||
<title>Jacob Test Applet</title> | ||
</head> | ||
<body> | ||
<applet code="com.jacob.samples.applet.JacobTestApplet" | ||
name="JacobTestApplet" | ||
width="400" | ||
height="50" | ||
alt="Please install java first! (Java is available for free at www.java.com)"> | ||
<param name="jnlp_href" value="Applet.jnlp"> | ||
Java is not working! Several reasons:<br/> | ||
1.) Your Browser is not able to execute java (-> get a different browser e.g. firefox.com)<br/> | ||
2.) Java is not installed (-> install java e.g. java.com)<br/> | ||
3.) Java is disabled/deactivated (-> enable java in your web browser)<br/> | ||
4.) Your security settings are too tight (->enable java the settings)<br/> | ||
5.) Contact support @ nepatec<br/> | ||
</applet> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<jnlp href="Applet.jnlp" spec="1.0+" version="1.1"> | ||
|
||
<information> | ||
<title>Jacob Test Applet</title> | ||
<vendor>ttreeck, nepatec GmbH & Co. KG</vendor> | ||
<offline-allowed /> | ||
</information> | ||
|
||
<security> | ||
<all-permissions/> | ||
</security> | ||
|
||
<resources> | ||
<j2se href="http://java.sun.com/products/autodl/j2se" version="1.6.0_20+" /> | ||
<jar href="lib/JacobTestApplet.jar-selfSigned.jar" main="true" version="1.0.0" /> | ||
<jar href="lib/jacob-signed.jar" version="1.0.0" /> | ||
<nativelib href="lib/jacob-dll-1.15-M3-signed.jar"/> | ||
</resources> | ||
|
||
<applet-desc | ||
name="JacobTestApplet" | ||
main-class="com.jacob.samples.applet.JacobTestApplet" | ||
width="400" | ||
height="50"> | ||
</applet-desc> | ||
</jnlp> |
88 changes: 88 additions & 0 deletions
88
jacob/samples/com/jacob/samples/applet/JacobTestApplet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package com.jacob.samples.applet; | ||
|
||
import java.applet.Applet; | ||
import java.awt.Button; | ||
import java.awt.FlowLayout; | ||
import java.awt.TextField; | ||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
|
||
import com.jacob.activeX.ActiveXComponent; | ||
import com.jacob.com.Dispatch; | ||
import com.jacob.com.Variant; | ||
|
||
/** | ||
* Example applet to demonstrate: | ||
* 1. The use of jacob from an applet | ||
* 2. To show how to distribute the jacob native lib with the applet (also works with webstart) | ||
* | ||
* Comment on 2.: | ||
* The way shown here is quite straight forward and it is not necessary to use | ||
* a mechanism like the "DLLFromJARClassLoader" or something similar... | ||
* | ||
* @author ttreeck, www.nepatec.de | ||
* | ||
*/ | ||
|
||
public class JacobTestApplet extends Applet implements ActionListener { | ||
|
||
private static final long serialVersionUID = 4492492907986849158L; | ||
|
||
TextField in; | ||
TextField out; | ||
Button calc; | ||
ActiveXComponent sC = null; | ||
|
||
/** | ||
* startup method | ||
*/ | ||
@Override | ||
public void init() { | ||
setLayout(new FlowLayout()); | ||
add(this.in = new TextField("1+1", 16)); | ||
add(this.out = new TextField("?", 16)); | ||
add(this.calc = new Button("Calculate")); | ||
this.calc.addActionListener(this); | ||
|
||
} | ||
|
||
/** | ||
* Returns information about this applet. | ||
* According to the java spec: | ||
* "An applet should override this method to return a String containing information about the author, version, and copyright of the applet." | ||
* | ||
* @return information about the applet. | ||
*/ | ||
@Override | ||
public String getAppletInfo() { | ||
return "Jacob Test Applet. Written by ttreeck, nepatec GmbH & Co. KG.\nhttp://www.nepatec.de"; | ||
} | ||
|
||
/** | ||
* Returns information about the parameters that are understood by this applet. | ||
* According to the java spec: | ||
* "An applet should override this method to return an array of Strings describing these parameters." | ||
* | ||
* @return array with a set of three Strings containing the name, the type, and a description. | ||
*/ | ||
|
||
@Override | ||
public String[][] getParameterInfo(){ | ||
return new String[][]{}; | ||
} | ||
|
||
/** | ||
* action method that receives button actions | ||
* | ||
* @param ev the event | ||
*/ | ||
public void actionPerformed(ActionEvent ev) { | ||
if (this.sC == null) { | ||
String lang = "VBScript"; | ||
this.sC = new ActiveXComponent("ScriptControl"); | ||
Dispatch.put(this.sC, "Language", lang); | ||
} | ||
Variant v = Dispatch.call(this.sC, "Eval", this.in.getText()); | ||
this.out.setText(v.toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
There is an easy and elegant way to load DLLs from Applets and JavaWebStart Applications. | ||
|
||
Both JavaWebStart and Applets support JNLP (Applets since 1.6.0_10 aka plugin2). | ||
Within a jnlp file it is possible to specify a nativelib and that's it! | ||
So what do you need to do? | ||
|
||
1.) package the jacob-1.XX-xXX.dll into a jar file (root level of the jar, not into a subfolder) and put it into your applications lib folder next to your other libs (e.g. jacob.jar) | ||
2.) Specify all your libraries in your jnlp file like this: | ||
|
||
<?xml version="1.0" encoding="UTF-8"?> | ||
<jnlp href="MyApplicaton.jnlp" spec="1.0+" version="1.1"> | ||
|
||
<information> | ||
<title>My cool Application or Applet</title> | ||
<vendor>nepatec GmbH & Co. KG</vendor> | ||
<offline-allowed /> | ||
</information> | ||
|
||
<security> | ||
<all-permissions/> | ||
</security> | ||
|
||
<resources> | ||
<j2se href="http://java.sun.com/products/autodl/j2se" version="1.6.0_10+" /> | ||
<jar href="MyCoolApp.jar" main="true" version="1.0.0" /> | ||
<jar href="jacob.jar" version="1.0.0" /> | ||
<nativelib href="jacob-1.XX-xXX.jar"/> | ||
</resources> | ||
|
||
<!-- Use either this for an applet --> | ||
<applet-desc | ||
name="MyCoolApp" | ||
main-class="de.nepatec.app.MyCoolApplet" | ||
width="265" | ||
height="60"> | ||
</applet-desc> | ||
|
||
<!-- or this for an web start application --> | ||
<application-desc main-class="de.nepatec.app.MyCoolApp"> | ||
<argument>some crazy arguments</argument> | ||
</application-desc> | ||
</jnlp> | ||
|
||
3.) Sign all the jars or set up a policy file (cp. Applet Security below) | ||
4.) Deploy your application and start it via webstart or as an applet (from an webpage) | ||
|
||
|
||
General comments: | ||
|
||
- If you sign the jar files you need the <security> tag - when using a policy file it can be removed | ||
- furthermore it is recommended that all libs are signed with an official certificate (e.g. from verisign, thawte etc) so that the browser doesn't pop a warning stating 'untrusted' application... | ||
- to check the validity of your jnlp file the tool JaNeLA (link cp. sources below) is recommended. | ||
|
||
[Sources] | ||
New Applet: https://jdk6.dev.java.net/plugin2/ | ||
Applet JNLP: https://jdk6.dev.java.net/plugin2/jnlp/ | ||
Applet Security: http://java.sun.com/developer/onlineTraining/Programming/JDCBook/appA.html | ||
JNLP API: http://www.oracle.com/technetwork/java/javase/index-141367.html | ||
JNLP Verifier: http://pscode.org/janela/ |
Binary file modified
BIN
-630 Bytes
(97%)
jacob/unittest/com/jacob/test/safearray/SafeArrayBasicTest.java
Binary file not shown.