Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
24 changes: 12 additions & 12 deletions sites/cheerpj/src/content/docs/10-getting-started/00-Java-app.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Run a Java application
title: Run a Java Application
description: Convert a desktop app to a webapp
---

Expand All @@ -10,12 +10,12 @@ Java source code is not needed to use CheerpJ. If you are building your own appl
**To get started you will need:**

- Your Java application file(s). You can also use this [TextDemo.jar](https://docs.oracle.com/javase/tutorialJWS/samples/uiswing/TextDemoProject/TextDemo.jar) sample.
- An HTML file where your Java app will be wrapped
- A simple HTTP server to test your webpage locally
- An HTML file where your Java app will be wrapped.
- A simple HTTP server to test your webpage locally.

## 1. Create a project directory

Let's start by creating a project folder where all your files will be. Please copy your java and future HTML files here.
Let's start by creating a project folder where all your files will be. Copy your java and future HTML files here.

```shell

Expand All @@ -32,7 +32,7 @@ Let's create a basic HTML file like the following example. Please notice the Che
<html lang="en">
<head>
<meta charset="utf-8" />
<title>CheerpJ test</title>
<title>CheerpJ Java App Example</title>
<script src="https://cjrtnc.leaningtech.com/4.2/loader.js"></script>
</head>
<body>
Expand All @@ -56,7 +56,7 @@ cheerpjRunMain(
);
```

> [!help] Don't forget to use the /app/ prefix
> [!note] Don't forget to use the /app/ prefix
> It is common for first-time users to forget to add the prefix “/app/” when passing the application location to cheerpJRunJar() or cheerpjRunMain().

## 3. Host your page
Expand All @@ -67,9 +67,13 @@ You can now serve this web page on a simple HTTP server, such as the http-server
npx http-server -p 8080
```

> [!tip]
> [!note] Info
> Opening the page directly from the disk (for example, by double-clicking on it) is not supported.

## The result

You will see the CheerpJ display on your browser with some loading messages before showing your application running. Depending on your application and the optimizations applied, this could take just a few seconds.

## What's going on?

- The `<head>` script loads CheerpJ.
Expand All @@ -78,13 +82,9 @@ npx http-server -p 8080
- [`cheerpjRunJar`] executes your application!
- `/app/` is a [virtual filesystem] mount point that references the root of the web server this page is loaded from.

## The result

You will see the CheerpJ display on your browser with some loading messages before showing your application running. Depending on your application and the optimizations applied, this could take just a few seconds.

### Is your application not working?

Please try these checks:
If your application doesn't work, check the following:

- The location of your JARs is correct and the prefix `/app/` is added when passing it to [`cheerpjRunJar`] or [`cheerpjRunMain`]. For more information visit the [virtual filesystem] guide.
- Your Java application works normally on your machine without CheerpJ.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Run a Java applet
title: Run a Java Applet
description: Run a java applet in modern browsers
---

Expand All @@ -23,7 +23,7 @@ CheerpJ can run Java applets in the browser seamlessly. This page will help you

## Running your own applet

**You will need:**
**To get started you will need:**

- Your applet file(s)
- The HTML file where your applet is meant to be displayed.
Expand Down Expand Up @@ -56,7 +56,7 @@ For example:
<html lang="en">
<head>
<meta charset="utf-8" />
<title>CheerpJ applet test</title>
<title>CheerpJ Applet Example</title>
<script src="https://cjrtnc.leaningtech.com/4.2/loader.js"></script>
</head>
<body>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Run a Java library
title: Run a Java Library
description: Use Java classes in JavaScript
---

Expand All @@ -13,15 +13,15 @@ Java source code is not required to use CheerpJ. If you are using your own libra
- An HTML file where your Java app will be wrapped.
- A simple HTTP server to test your webpage locally.

## 1. Create a Project Directory
## 1. Create a project directory

Let's start by creating a project folder where all your files will be. Copy your java and future HTML files here.

```shell
mkdir directory_name
```

## 2. Create a Basic HTML File
## 2. Create a basic HTML file

Let's create a basic HTML file and include and initialize CheerpJ on your page. The `cheerpjInit` command initialises the CheerpJ runtime environment.

Expand All @@ -41,7 +41,7 @@ Let's create a basic HTML file and include and initialize CheerpJ on your page.
</html>
```

## 3. Load and Call the Java Library From Java
## 3. Load and call the Java library from JavaScript

Now we can load your Java library by calling `cheerpjRunLibrary` which will load the library from the root of your web server. We are assuming your HTML file and your `.jar` files are under the project directory you just created.

Expand All @@ -50,7 +50,7 @@ Now we can load your Java library by calling `cheerpjRunLibrary` which will load
<html lang="en">
<head>
<meta charset="utf-8" />
<title>CheerpJ Library Mode Test</title>
<title>CheerpJ Library Mode Example</title>
<script src="https://cjrtnc.leaningtech.com/4.2/loader.js"></script>
</head>
<body>
Expand All @@ -66,15 +66,15 @@ Now we can load your Java library by calling `cheerpjRunLibrary` which will load
</html>
```

## 3. Host your page
## 4. Host your page

You can now serve this web page on a simple HTTP server, such as the http-server utility.

```shell
npx http-server -p 8080
```

## The Result
## The result

You will see CheerpJ initialize in your browser and load the Java library. Once loaded, the methods from your library can be called directly from JavaScript, just as in the example above. Depending on the size of your library and the optimizations applied, this may take just a few seconds before your code begins executing.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This quickstart tutorial will take you step by step on how to run your JNLP app
<JNLPRunnerButton />
</div>

You will need:
**To get started you will need:**

- The application `.jnlp` file.
- An HTML file where your Java app will be wrapped.
Expand Down Expand Up @@ -217,7 +217,7 @@ cd directory_name
npx http-server -p 8080
```

## The end
## Further reading

This is the end of the tutorial. To learn more about running standalone applications and applets with CheerpJ, you can visit the dedicated tutorials:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default {
<!doctype html>
<html>
<head>
<title>Native Method Example</title>
<title>Native Library Example</title>
<script src="https://cjrtnc.leaningtech.com/4.2/loader.js"></script>
</head>
<body>
Expand Down