Upload and download files
How to interact with the local filesystem using the JNLP Runner extension
The CheerpJ JNLP Runner extension provides a virtual filesystem that allows Java Web Start applications to read and write files within the browser’s sandbox. Since browsers cannot access your local disk directly for security reasons, CheerpJ provides two main ways to move files into and out of this virtual space.
Method 1: Using the extension popup
The extension popup (accessible by clicking the CheerpJ icon in your browser’s toolbar) provides direct controls for file handling once the extension is enabled on a page.
Uploading files
To import a local file to the virtual filesystem:
- Click the Upload button in the extension popup.
- Select the file(s) from your local machine.
- The files will be automatically placed in the
/files/uploads/directory.
Inside the Java application, you can then navigate to /files/uploads/ to open or import these files.
Downloading files
Any file that the Java application saves to the /files/downloads/ directory will be automatically detected and downloaded by your browser to your local machine (usually your default Downloads folder).
To export data, simply ensure the applet’s save path is set to /files/downloads/.
Method 2: Using the built-in file picker (JFileChooser)
If the Java application uses a standard JFileChooser dialog, CheerpJ provides an integrated way to handle local files without leaving the application’s UI.
Integrated Upload
The JFileChooser dialog in CheerpJ features an upload button (upward arrow icon) in the top-right corner.
- Click the upload button within the file picker.
- Select a file from your local machine.
- The file is automatically uploaded to the virtual filesystem at
/files/uploads/. - In the
JFileChooser, navigate to/files/uploads/and select the file to load it into the application.
Integrated Download
Similarly, if you use a “Save” dialog and choose a path under /files/downloads/, the browser will automatically trigger a download of the file to your local machine once the save operation is complete.