Unable to Install Java Package as a Library

There is a java package called ‘com.dd.plist’ that I would like to install as a library in Processing 4.4.10 (https://github.com/3breadt/dd-plist). It contains 28 individual files and has no available .jar file. The only way that I can sort of get it to work is to drag 'n drop the files individually onto the sketch opened in the editor. However, doing that for all 28 files is not practical. I have tried adding a folder to Processing/libraries and then creating a nested folder entitled ‘library’ containing the /com/dd/plist folders. It’s unclear to me what to name the Processing/libraries/??? folder; nothing that I have tried so far seems to work. The package name is ‘com.dd.plist’ but Processing seems to think the package is ‘com.dd’ according to the error message. Thanks in advance for any insight into how I can do this.

Source code:

import com.dd.plist.*;
import java.io.File;

void setup() {
  surface.setVisible(false);
  try {
    // Create the root dictionary
    NSDictionary rootDict = new NSDictionary();

    // Add standard Info.plist keys
    rootDict.put("CFBundleName", "MyJavaApp");
    rootDict.put("CFBundleExecutable", "universalJavaApplicationStub"); // Common for bundled apps
    rootDict.put("CFBundleIdentifier", "com.example.myjavaapp");
    rootDict.put("CFBundleVersion", "1.0");
    rootDict.put("LSUIElement", true); // Example of a boolean key

    // Define Java-specific keys within a "Java" dictionary (optional, for older configs)
    NSDictionary javaDict = new NSDictionary();
    javaDict.put("ClassPath", "$JAVAROOT/my-app.jar");
    javaDict.put("MainClass", "com.example.MyMainClass");
    rootDict.put("Java", javaDict);

    // Write the dictionary to a file in XML format
    File outFile = new File("Info.plist");
    PropertyListParser.saveAsXML(rootDict, outFile);
    println("Info.plist created successfully at: " + outFile.getAbsolutePath());

    // You can also save in binary format if needed
    // PropertyListParser.saveAsBinary(rootDict, outFile);
  }
  catch (Exception e) {
    e.printStackTrace();
  }
}

Error mesage:

No library found for com.dd.plist
Libraries must be installed in a folder named 'libraries' inside the sketchbook folder (see the Preferences window).
The package “com.dd” does not exist. You might be missing a library.

Releases:

I am seeing a JAR file in there:

This appears to be for macOS only.

:)

1 Like

I downloaded the package from the ‘Code‘ button and did not look under the ‘Releases‘ button where the .jar was located. Thanks for the tip. After drag ‘n dropping the .jar file I’m now one step closer to getting it to work; the old error message is gone but now there is a null pointer exception that I’ll try to fix.

Correct, but it can potentially be used by a cross-platform Processing app to create a mac app, however, this remains to be seen.

Addendum:

Binary format output after null pointer fix:

1 Like