Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7409889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:09:00+00:00 2026-05-29T06:09:00+00:00

First time posting here, will try to be succinct. This is a classic ‘can’t

  • 0

First time posting here, will try to be succinct. This is a classic ‘can’t access file within an Applet’ problem, but I’m having a particular difficulty with it.

I’m trying to rewrite this file:

A JavaSound test for libpd

into a template applet to load libpd (https://github.com/libpd/libpd) patches made in PureData (puredata.info)…this already works in a normal Main function in a non-applet Java program (see above), where the main function finds the patch using:

PdBase.openAudio(0, outChans, (int) sampleRate);
    int patch = PdBase.openPatch("samples/com/noisepages/nettoyeur/libpd/sample/test.pd");
    PdBase.computeAudio(true);

The reason it tries to load the path and file into a int variable is that the core function itself does this with:

public synchronized static int openPatch(File file) throws IOException {
    if (!file.exists()) {
        throw new FileNotFoundException(file.getPath());
    }
    String name = file.getName();
    File dir = file.getParentFile();
    long ptr = openFile(name, (dir != null) ? dir.getAbsolutePath() : ".");
    if (ptr == 0) {
        throw new IOException("unable to open patch " + file.getPath());
    }
    int handle = getDollarZero(ptr);
    patches.put(handle, ptr);
    return handle;
}
public synchronized static int openPatch(String path) throws IOException {
    return openPatch(new File(path));
}

This is because PD tries to identify each patch by giving an int ‘handle’ (dollarZero, for legacy reasons), so that int handle gets passed around to open and close the patch file.

So now. I’m trying to load the same file in an Applet, so since I believe it runs ‘in the client’ and won’t know what path I’m talking about, I read up on java.net.URL and tried to build variations of:

        patchURL = new URL("test.pd");
    PdBase.openPatch(patchURL.getPath().toString());

and

URL url = this.getClass().getResource("test.pd");

inspired by previous questionsin the init() and start() functions of the applet, turning the original main into a local static method sound().

All I get is null pointers. I would’ve thought all I needed was a simple getDocumentBase(), but can’t seem to make it work. Anyone?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:09:01+00:00Added an answer on May 29, 2026 at 6:09 am

    libpd is just a thin wrapper on top of Pure Data, and Pure Data doesn’t know about URLs or input streams in Java. The openPatch method merely sends the patch name and directory to Pd, and then Pd will try to open the corresponding file. So, applets are out, unless you’re willing to tinker with security policies.

    About finding files, the simple sample program is part of the libpd Eclipse project. It’s meant to be run in Eclipse, and the hard-coded path to the patch is relative to the project root in Eclipse. If you want your code to run in a different setting, you have to adjust your paths accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first time posting here, I have a question which I have
this is my first time posting here, but I didn't know where else to
This is my first time posting a question here, it has been a valuable
This is my first time posting here, but I've found a lot of answers
First time posting on here, so I hope I do this correctly, however I
this is my first time posting a question here - I've searched for ones
first time posting here, but god know's I use this site to search for
This is my first time posting here, so please be kind ;-) EDIT My
this is my first time posting my problem here, i hope i get help
first time posting here. I'm using a loop to create 3 buttons, but my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.