Upload and download files

How to interact with the local filesystem using the Applet Runner extension

For a deeper dive into how file systems work in CheerpJ, check out the File System explanation guide.

The extension gives Java applets a virtual filesystem, so they can read and write files inside the browser’s sandbox. The browser doesn’t let it reach your disk directly, so files move in by upload and out by download.

Uploading files

To import a file from your local machine to the virtual filesystem, you can use either the built-in file picker or the extension popup. In both cases, the files will be placed in the /files/uploads/ virtual directory. Inside the Java applet, you can navigate to /files/uploads/ to open or use these files.

Using the built-in file picker:

The upload icon (an upward arrow) is present as part of the title bar on any Java window, frame, or File Dialog that opens.

Undecorated Applet frames
The main Applet frame is normally undecorated, meaning it will not have a title bar. If the applet does not open any additional windows or file dialogs that have a title bar, you will need to use the extension popup to upload files.

A Java File Dialog window highlighting the upward-arrow upload icon
integrated into its title bar

  1. Click the upload icon in the title bar.
  2. Select a file from your local file system (your machine).
  3. In the File Dialog, navigate to /files/uploads/ and select the file to load it into the applet.

Using the extension popup:

Alternatively, you can upload files directly from the extension popup.

Pin the extension
If you cannot see the extension popup icon, you may need to pin the extension to your browser’s toolbar.
  1. Ensure the Java applet is currently running.

  2. Click the extension’s icon in the toolbar, then Upload file.

    Extension popup showing the Upload file button enabled while an Applet is
running

  3. Select the file(s) from your local filesystem.

Downloading files

To get a file out of the applet, save it in the /files/downloads/ virtual directory. The browser downloads every file saved there, usually to your Downloads folder.

Using a standard save dialog:

If you use a “Save” File Dialog and choose a path under /files/downloads/, the browser will automatically trigger a download once the save operation is complete.