Skip to content

Commit ede7d21

Browse files
author
clay_shooter
committed
Finally moved up to 1.15. Also added 3137337 JNLP Example
1 parent cd963dd commit ede7d21

File tree

7 files changed

+200
-59
lines changed

7 files changed

+200
-59
lines changed

jacob/docs/ReleaseNotes.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<HTML>
22
<BODY>
33
<!-- --------- -->
4-
<h2>JACOB 1.15 M4</h2>
4+
<h2>JACOB 1.15</h2>
55
<h3>What's New</h3>
66
<ul>
77
<li>
@@ -65,6 +65,11 @@ <h3>Tracked Changes</h3>
6565
<tr>
6666
<td colspan="2"><b>Feature Requests</b></td>
6767
</tr>
68+
<tr>
69+
</tr>
70+
<td width="13%" valign="top">3137337</td>
71+
<td width="87%" valign="top">Add JNLP Applet example. Read the README to understand what jar
72+
file signing and file placement is required</td>
6873
<tr>
6974
<td width="13%" valign="top">2963102</td>
7075
<td width="87%" valign="top">Convert API to use var args and remove the many overloaded Dispatch

jacob/samples/com/jacob/samples/applet/AppTest.java

Lines changed: 0 additions & 58 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<html>
2+
<head>
3+
<title>Jacob Test Applet</title>
4+
</head>
5+
<body>
6+
<applet code="com.jacob.samples.applet.JacobTestApplet"
7+
name="JacobTestApplet"
8+
width="400"
9+
height="50"
10+
alt="Please install java first! (Java is available for free at www.java.com)">
11+
<param name="jnlp_href" value="Applet.jnlp">
12+
Java is not working! Several reasons:<br/>
13+
1.) Your Browser is not able to execute java (-> get a different browser e.g. firefox.com)<br/>
14+
2.) Java is not installed (-> install java e.g. java.com)<br/>
15+
3.) Java is disabled/deactivated (-> enable java in your web browser)<br/>
16+
4.) Your security settings are too tight (->enable java the settings)<br/>
17+
5.) Contact support @ nepatec<br/>
18+
</applet>
19+
</body>
20+
</html>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<jnlp href="Applet.jnlp" spec="1.0+" version="1.1">
3+
4+
<information>
5+
<title>Jacob Test Applet</title>
6+
<vendor>ttreeck, nepatec GmbH &amp; Co. KG</vendor>
7+
<offline-allowed />
8+
</information>
9+
10+
<security>
11+
<all-permissions/>
12+
</security>
13+
14+
<resources>
15+
<j2se href="http://java.sun.com/products/autodl/j2se" version="1.6.0_20+" />
16+
<jar href="lib/JacobTestApplet.jar-selfSigned.jar" main="true" version="1.0.0" />
17+
<jar href="lib/jacob-signed.jar" version="1.0.0" />
18+
<nativelib href="lib/jacob-dll-1.15-M3-signed.jar"/>
19+
</resources>
20+
21+
<applet-desc
22+
name="JacobTestApplet"
23+
main-class="com.jacob.samples.applet.JacobTestApplet"
24+
width="400"
25+
height="50">
26+
</applet-desc>
27+
</jnlp>
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package com.jacob.samples.applet;
2+
3+
import java.applet.Applet;
4+
import java.awt.Button;
5+
import java.awt.FlowLayout;
6+
import java.awt.TextField;
7+
import java.awt.event.ActionEvent;
8+
import java.awt.event.ActionListener;
9+
10+
import com.jacob.activeX.ActiveXComponent;
11+
import com.jacob.com.Dispatch;
12+
import com.jacob.com.Variant;
13+
14+
/**
15+
* Example applet to demonstrate:
16+
* 1. The use of jacob from an applet
17+
* 2. To show how to distribute the jacob native lib with the applet (also works with webstart)
18+
*
19+
* Comment on 2.:
20+
* The way shown here is quite straight forward and it is not necessary to use
21+
* a mechanism like the "DLLFromJARClassLoader" or something similar...
22+
*
23+
* @author ttreeck, www.nepatec.de
24+
*
25+
*/
26+
27+
public class JacobTestApplet extends Applet implements ActionListener {
28+
29+
private static final long serialVersionUID = 4492492907986849158L;
30+
31+
TextField in;
32+
TextField out;
33+
Button calc;
34+
ActiveXComponent sC = null;
35+
36+
/**
37+
* startup method
38+
*/
39+
@Override
40+
public void init() {
41+
setLayout(new FlowLayout());
42+
add(this.in = new TextField("1+1", 16));
43+
add(this.out = new TextField("?", 16));
44+
add(this.calc = new Button("Calculate"));
45+
this.calc.addActionListener(this);
46+
47+
}
48+
49+
/**
50+
* Returns information about this applet.
51+
* According to the java spec:
52+
* "An applet should override this method to return a String containing information about the author, version, and copyright of the applet."
53+
*
54+
* @return information about the applet.
55+
*/
56+
@Override
57+
public String getAppletInfo() {
58+
return "Jacob Test Applet. Written by ttreeck, nepatec GmbH & Co. KG.\nhttp://www.nepatec.de";
59+
}
60+
61+
/**
62+
* Returns information about the parameters that are understood by this applet.
63+
* According to the java spec:
64+
* "An applet should override this method to return an array of Strings describing these parameters."
65+
*
66+
* @return array with a set of three Strings containing the name, the type, and a description.
67+
*/
68+
69+
@Override
70+
public String[][] getParameterInfo(){
71+
return new String[][]{};
72+
}
73+
74+
/**
75+
* action method that receives button actions
76+
*
77+
* @param ev the event
78+
*/
79+
public void actionPerformed(ActionEvent ev) {
80+
if (this.sC == null) {
81+
String lang = "VBScript";
82+
this.sC = new ActiveXComponent("ScriptControl");
83+
Dispatch.put(this.sC, "Language", lang);
84+
}
85+
Variant v = Dispatch.call(this.sC, "Eval", this.in.getText());
86+
this.out.setText(v.toString());
87+
}
88+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
There is an easy and elegant way to load DLLs from Applets and JavaWebStart Applications.
2+
3+
Both JavaWebStart and Applets support JNLP (Applets since 1.6.0_10 aka plugin2).
4+
Within a jnlp file it is possible to specify a nativelib and that's it!
5+
So what do you need to do?
6+
7+
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)
8+
2.) Specify all your libraries in your jnlp file like this:
9+
10+
<?xml version="1.0" encoding="UTF-8"?>
11+
<jnlp href="MyApplicaton.jnlp" spec="1.0+" version="1.1">
12+
13+
<information>
14+
<title>My cool Application or Applet</title>
15+
<vendor>nepatec GmbH &amp; Co. KG</vendor>
16+
<offline-allowed />
17+
</information>
18+
19+
<security>
20+
<all-permissions/>
21+
</security>
22+
23+
<resources>
24+
<j2se href="http://java.sun.com/products/autodl/j2se" version="1.6.0_10+" />
25+
<jar href="MyCoolApp.jar" main="true" version="1.0.0" />
26+
<jar href="jacob.jar" version="1.0.0" />
27+
<nativelib href="jacob-1.XX-xXX.jar"/>
28+
</resources>
29+
30+
<!-- Use either this for an applet -->
31+
<applet-desc
32+
name="MyCoolApp"
33+
main-class="de.nepatec.app.MyCoolApplet"
34+
width="265"
35+
height="60">
36+
</applet-desc>
37+
38+
<!-- or this for an web start application -->
39+
<application-desc main-class="de.nepatec.app.MyCoolApp">
40+
<argument>some crazy arguments</argument>
41+
</application-desc>
42+
</jnlp>
43+
44+
3.) Sign all the jars or set up a policy file (cp. Applet Security below)
45+
4.) Deploy your application and start it via webstart or as an applet (from an webpage)
46+
47+
48+
General comments:
49+
50+
- If you sign the jar files you need the <security> tag - when using a policy file it can be removed
51+
- 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...
52+
- to check the validity of your jnlp file the tool JaNeLA (link cp. sources below) is recommended.
53+
54+
[Sources]
55+
New Applet: https://jdk6.dev.java.net/plugin2/
56+
Applet JNLP: https://jdk6.dev.java.net/plugin2/jnlp/
57+
Applet Security: http://java.sun.com/developer/onlineTraining/Programming/JDCBook/appA.html
58+
JNLP API: http://www.oracle.com/technetwork/java/javase/index-141367.html
59+
JNLP Verifier: http://pscode.org/janela/
Binary file not shown.

0 commit comments

Comments
 (0)