Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CJ docs edits #23

Merged
merged 9 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified public/cheerpj3/examples/applet-template.zip
Binary file not shown.
33 changes: 26 additions & 7 deletions src/content/docs/cheerpj2/03-getting-started/01-Java-applet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,32 @@ CheerpJ can run Java applets in the browser seamlessly. This page will help you
**You will need:**

- Your applet file(s)
- An HTML file to wrap your applet
- The HTML file where your applet is meant to be displayed.
- A basic HTTP server to test locally

### 1. Create a basic HTML file
### 1. Integrating CheerpJ in your HTML file

```html title="index.html" {6-9,12-19}
This example assumes you already have your own HTML file displaying your applet using `<applet>`, `<object>` or `<embed>`.
GabrielaReyna marked this conversation as resolved.
Show resolved Hide resolved

In order to integrate CheerpJ, you just need to add:

1. A simple `<script>` within the `<head>` of your page with the CheerpJ runtime loader.

```html
<script src="https://cjrtnc.leaningtech.com/2.3/loader.js"></script>
```

2. A second script calling `cheerpjInit()`

```html
<script>
cheerpjInit({ enablePreciseAppletArchives: true });
</script>
```

For example:

```html title="index.html" {6-9}
<!doctype html>
<html lang="en">
<head>
Expand All @@ -33,14 +53,14 @@ CheerpJ can run Java applets in the browser seamlessly. This page will help you
</script>
</head>
<body>
<cheerpj-applet
<applet
archive="Example.jar"
code="ExamplePath.ExampleApplet"
height="900"
width="900"
>
<p>not able to load Java applet</p>
</cheerpj-applet>
</applet>
</body>
</html>
```
Expand All @@ -56,8 +76,7 @@ http-server -p 8080

### What's going on?

- The `cheerpjInit({enablePreciseAppletArchives:true});` initializes CheerpJ runtime environment indicating we are loading an applet.
- The `<cheerpj-applet>` tag specifies the code base in a similar manner as the now deprecated `<applet>` tag.
- The `cheerpjInit({enablePreciseAppletArchives:true})` initializes CheerpJ runtime environment indicating we are loading an applet.

> To avoid potential conflicts with native Java we recommend replacing the original HTML tag with `cheerpj-` prefixed version. You should use `<cheerpj-applet>`, `<cheerpj-object>` or `<cheerpj-embed>` depending on the original tag.
GabrielaReyna marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
35 changes: 27 additions & 8 deletions src/content/docs/cheerpj3/10-getting-started/01-Java-applet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,40 @@ CheerpJ can run Java applets in the browser seamlessly. This page will help you

**There are two different ways to run a Java Applet in the browser:**

- [Running your own Java applet](/cheerpj3/getting-started/Java-applet#running-your-own-applet) using the CheerpJ runtime environment and the `<cheerpj-applet>` tag in your own webpage.
- [Running your own Java applet](/cheerpj3/getting-started/Java-applet#running-your-own-applet) using the CheerpJ runtime environment in your own webpage.
- [Running a public applet](/cheerpj3/getting-started/Java-applet#running-a-public-applet) using the [CheerpJ Applet Runner](https://chrome.google.com/webstore/detail/cheerpj-applet-runner/bbmolahhldcbngedljfadjlognfaaein) Chrome extension for applets integrated with the applet tag `<applet>` on public websites.

## Running your own applet

**You will need:**

- Your applet file(s)
- An HTML file to wrap your applet
- The HTML file where your applet is meant to be displayed.
- A basic HTTP server to test locally

### 1. Create a basic HTML file
### 1. Integrating CheerpJ in your HTML file

```html title="index.html" {6, 9-17}
This example assumes you already have your own HTML file displaying your applet using `<applet>`, `<object>` or `<embed>`.

In order to integrate CheerpJ, you just need to add:

1. A simple `<script>` within the `<head>` of your page with the CheerpJ runtime loader.

```html
<script src="https://cjrtnc.leaningtech.com/3.0rc1/cj3loader.js"></script>
```

2. A second script calling `cheerpjInit()`

```html
<script>
await cheerpjInit();
GabrielaReyna marked this conversation as resolved.
Show resolved Hide resolved
</script>
```

For example:

```html title="index.html" {6, 15-17}
<!doctype html>
<html lang="en">
<head>
Expand All @@ -30,14 +50,14 @@ CheerpJ can run Java applets in the browser seamlessly. This page will help you
<script src="https://cjrtnc.leaningtech.com/3.0rc1/cj3loader.js"></script>
</head>
<body>
<cheerpj-applet
<applet
archive="Example.jar"
code="ExamplePath.ExampleApplet"
height="900"
width="900"
></cheerpj-applet>
></applet>
<script>
cheerpjInit();
await cheerpjInit();
</script>
</body>
</html>
Expand All @@ -55,7 +75,6 @@ http-server -p 8080
### What's going on?

- The `cheerpjInit();` initializes CheerpJ runtime environment.
GabrielaReyna marked this conversation as resolved.
Show resolved Hide resolved
- The `<cheerpj-applet>` tag specifies the code base in a similar manner as the now deprecated `<applet>` tag.

> To avoid potential conflicts with native Java we recommend replacing the original HTML tag with `cheerpj-` prefixed version. You should use `<cheerpj-applet>`, `<cheerpj-object>` or `<cheerpj-embed>` depending on the original tag.

Expand Down