Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
295 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
target | ||
*/.settings | ||
*/target | ||
**/*/.settings | ||
**/*/target | ||
**/*/dependency-reduced-pom.xml |
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 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,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
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,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>webcam-capture-example-applet</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
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,78 @@ | ||
# Webcam Capture Example Applet | ||
|
||
This example presents how to create Java Applet using Webcam Capture project. | ||
|
||
## Generate Java Keystore | ||
|
||
Since our Applet will be using users hardware, we have to either sign it, or | ||
specify appropriate permissions. Without doing this user will get ```SecurityPermissionException``` | ||
when trying to use Applet. This is because Java restrict access to various system elements | ||
(filesystem, hardware, etc). But when you sign application, Java assume it is safe (since | ||
you signed it with your personal certificate), and grant access to the system hardware. | ||
|
||
Therefore, before you start build you have to generate Java keystore which will be used | ||
later by Maven to sign Applet JAR. To do that you have to use ```keytool``` program | ||
available within JDK ```bin``` directory. | ||
|
||
``` | ||
$ keytool -genkey -alias example -keyalg RSA -keystore keystore.jks -keysize 2048 | ||
``` | ||
|
||
After executing this command, ```keytool``` will ask you to provide all required information, | ||
such as: | ||
|
||
* Keystore password, | ||
* First and last name, | ||
* Your organizational unit name, | ||
* Your organization name, | ||
* City or Locality, | ||
* State or Province name, | ||
* Two-letter country code for this unit, | ||
* Key password for alias (in this case alias is _example_). | ||
|
||
In this example, in root directory, I included predefined keystore with alias | ||
_example_ with password _test1234_. | ||
|
||
## How To Build | ||
|
||
Like in all my other projects you have to have Maven 3.0 or later available in ```PATH```. | ||
You can download Maven binaries from **[here](http://maventest.apache.org/download.html)**. | ||
|
||
When you have Maven on your PC, it's enough to run this command to build project: | ||
|
||
``` | ||
$ mvn clean install | ||
``` | ||
|
||
This will caus ```target``` directory to be created. You will find output JAR there together | ||
with ```index.html``` which should be deployed along with this JAR. | ||
|
||
## Where Are All Required JARs? | ||
|
||
None is required. That's because I used _maven-shade-plugin_ to merge all JARs together so | ||
you will get only one JAR with all required classes inside (known as shaded JAR). | ||
|
||
For more details I suggest to check ```pom.xml```. | ||
|
||
## How To Sign JAR? | ||
|
||
You don't have to. Maven will do that for you. This has been done by using _maven-jarsigner-plugin_ | ||
which is using ```keystore.jks``` file to get self-signed certificate and use it to sign the JAR. | ||
|
||
## How To Upload Applet To Server? | ||
|
||
Use FTP client of your choice and upload these files to the remote site: | ||
|
||
* ```webcam-capture-example-applet-[version].jar``` | ||
* ```index.html``` | ||
|
||
You can also modify ```pom.xml``` and add [maven-upload-plugin](http://docs.atlassian.com/maven-upload-plugin/1.1/usage.html) | ||
to automatically upload specific files to the server when running ```mvn deploy```. | ||
|
||
## How To Run | ||
|
||
Simply access remote site URL. Follow the security confirmation dialog and enjoy | ||
this example. | ||
|
||
|
||
|
Binary file not shown.
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,103 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>com.github.sarxos</groupId> | ||
<artifactId>webcam-capture-parent</artifactId> | ||
<version>0.3.5</version> | ||
</parent> | ||
|
||
<artifactId>webcam-capture-example-applet</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>Webcam Capture - Applet Example</name> | ||
<description>Example of how to use Webcam Capture within Java Applet</description> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.github.sarxos</groupId> | ||
<artifactId>webcam-capture</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.3.2</version> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<version>2.6</version> | ||
<executions> | ||
<execution> | ||
<phase>prepare-package</phase> | ||
<goals> | ||
<goal>copy-resources</goal> | ||
</goals> | ||
<configuration> | ||
<outputDirectory>${project.build.directory}</outputDirectory> | ||
<overwrite>true</overwrite> | ||
<resources> | ||
<resource> | ||
<directory>src/main/html</directory> | ||
<includes> | ||
<include>**/*.html</include> | ||
</includes> | ||
</resource> | ||
</resources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>2.0</version> | ||
<configuration> | ||
<artifactSet> | ||
<includes> | ||
<include>*:*</include> | ||
</includes> | ||
</artifactSet> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jarsigner-plugin</artifactId> | ||
<configuration> | ||
<keystore>keystore.jks</keystore> | ||
<alias>example</alias> | ||
<storepass>test1234</storepass> | ||
<keypass>test1234</keypass> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>sign</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
|
||
</build> | ||
|
||
</project> |
Binary file added
BIN
+77.2 KB
webcam-capture-examples/webcam-capture-applet/src/etc/resources/applet.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+16.9 KB
webcam-capture-examples/webcam-capture-applet/src/etc/resources/security.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions
13
webcam-capture-examples/webcam-capture-applet/src/main/html/index.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,13 @@ | ||
<html> | ||
<head> | ||
<title>Webcam Capture Example Applet</title> | ||
</head> | ||
<body> | ||
<p>This is my page, below you see an Webcam Capture applet</p> | ||
<applet codebase="." | ||
archive="webcam-capture-example-applet-0.3.5.jar" | ||
code="com/github/sarxos/webcam/WebcamAppletExample.class" | ||
width="400" height="400" alt="Applet"> | ||
</applet> | ||
</body> | ||
</html> |
26 changes: 26 additions & 0 deletions
26
...les/webcam-capture-applet/src/main/java/com/github/sarxos/webcam/WebcamAppletExample.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,26 @@ | ||
package com.github.sarxos.webcam; | ||
|
||
import javax.swing.JApplet; | ||
|
||
|
||
public class WebcamAppletExample extends JApplet { | ||
|
||
private static final long serialVersionUID = 3517366452510566924L; | ||
|
||
private Webcam webcam = null; | ||
|
||
public WebcamAppletExample() { | ||
super(); | ||
} | ||
|
||
@Override | ||
public void start() { | ||
webcam = Webcam.getDefault(); | ||
add(new WebcamPanel(webcam)); | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
webcam.close(); | ||
} | ||
} |
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