Skip to content

YAMLScript in Java on Windows [10] tries to load Linux .so shared library #269

Closed

Description

@PH0lder

Attempting my first example of YAMLScript in Eclipse 2026-06 on Windows 10. Am getting this error, implying it thinks it's on Linux instead of Windows. I'm using JDK 26 ( OpenJDK Runtime Environment Temurin-26.0.1+8 (build 26.0.1+8) ) and Maven with this setup

  <repositories>
    <repository>
      <id>clojars.org</id>
      <url>https://repo.clojars.org</url>
    </repository>
  </repositories>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
    </dependency>
    <dependency>
      <groupId>org.yamlscript</groupId>
      <artifactId>yamlscript</artifactId>
      <version>0.2.22</version>
    </dependency>
  </dependencies>

This is the error I get:
Exception in thread "main" java.lang.RuntimeException: Shared library file libys.so.0.2.22 not found

I separately downloaded and extracted the libys.DLL and put it in the correct place and then even tried to pre-load it with:

  // Put the DLL in the root project directory
  // Add the JVM parameter: --enable-native-access=ALL-UNNAMED
  static
  {
    // Looks for a file named "libys.dll" (which is the ys shared library)
    System.loadLibrary("libys"); 
  }

Which seemingly succeeds in loading the DLL but I still get the error above.

This is my entire code, should it be relevant:

import org.json.JSONObject;
import org.yamlscript.yamlscript.YAMLScript;

public final class YAMLScriptExampleMain
{
  static final String EXAMPLE_YS_FILE = "example.yaml";
  static final String EXAMPLE_KEY = "ExamplePath";

  // Put the DLL in the root project directory
  // Add the JVM parameter: --enable-native-access=ALL-UNNAMED
  static
  {
    // Looks for a file named "libys.dll" (which is the ys shared library)
    System.loadLibrary("libys"); 
  }

  public static void main(final String[] args)
  {
    JSONObject jsonObject = YAMLScript.loadJSON(EXAMPLE_YS_FILE);
    jsonObject.get(EXAMPLE_KEY);
  }
}

This is my entire output

Exception in thread "main" java.lang.RuntimeException: Shared library file libys.so.0.2.22 not found
Try: curl -sSL https://yamlscript.org/install | VERSION=0.2.22 LIB=1 bash
See: https://github.com/yaml/yamlscript/wiki/Installing-YAMLScript
	at org.yamlscript.yamlscript.LibYS.path(LibYS.java:55)
	at org.yamlscript.yamlscript.LibYS.load(LibYS.java:70)
	at org.yamlscript.yamlscript.LibYS.library(LibYS.java:77)
	at org.yamlscript.yamlscript.YAMLScript.<init>(YAMLScript.java:78)
	at org.yamlscript.yamlscript.YAMLScript.loadJSON(YAMLScript.java:70)
	at indie.pholder.example.yamlscript.YAMLScriptExampleMain.main(YAMLScriptExampleMain.java:20)

Activity

  1. ingydotnet commented on Jun 24, 2026

    @ingydotnet
    Member

    @PH0lder Thanks for reporting this.

    I just released 0.2.23 which should take care of this. Please let me know if it does or does not.

    I wasn't testing the bindings on Windows in GitHub Actions CI before. Now I am for most languages, including Java.

    I'm not a regular user of Window or Java so any feedback you can provide would be useful.

    Would it be better to release this to Maven Central rather than Clojars? I might do that for the next release.

  2. PH0lder commented on Jun 25, 2026

    @PH0lder
    Author

    Yes, 0.2.23 worked for me, although I am missing any docs on how to make the library work for me. I guessed around a bit, and got a sample file from the YAMLStar repository and some clues. It really begs for a more Java oriented wrapper around it all, as casting is kinda not idiomatic Java. I've included the code that eventually worked, should it be helpful for anyone else who should also be new to this and need some direction.

    It would be possibly helpful to put it in the main maven repository, but just documenting the needed repository entry to get it where it is is also find as far as I am concerned.

    I enabled actual scripting and used it to get the ENV.USERPROFILE value successfully. This lead me to wonder if there would be an easy way to detect the platform in the YAMLScript so I could make conditional code depending on whether it was Windows or Linux (or Mac, although I don't usually go there ;) )

    This was my YAMLScript file

    !ys-0:
    database:
      profilepath:: ENV.USERPROFILE
      examplePath: examplePathValue
      host: localhost
      port: 5432
      credentials:
        username: admin
        password: secret
    

    And this was my code

    import java.io.IOException;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    import java.util.List;
    
    import org.json.JSONObject;
    import org.yamlscript.yamlscript.YAMLScript;
    
    public final class YAMLScriptExampleMain
    {
      static final String EXAMPLE_YS_FILE = "example.yaml";
      static final String EXAMPLE_KEY = "examplePath";
      static final String EXAMPLE_KEY_EXPECTED_VALUE = "examplePathValue";
    
      // Put the DLL in the root project directory
      // Add the JVM parameter: --enable-native-access=ALL-UNNAMED
      // static
      // {
      //   Looks for a file named "libys.dll" (which is the ys shared library)
      //   System.loadLibrary("libys"); 
      // }
    
      public static void main(final String[] args)
      {
        final List<String> yamlLines;
        try
        {
          yamlLines = Files.readAllLines(Paths.get(EXAMPLE_YS_FILE));
        }
        catch (final IOException e)
        {
          throw new IllegalStateException("Couldn't load YAML file: " + EXAMPLE_YS_FILE, e);
        }
    
        final StringBuilder sb = new StringBuilder();
        for (final String str : yamlLines)
        {
          sb.append(str);
          sb.append('\n');
        }
    
        final JSONObject config = (JSONObject)YAMLScript.load(sb.toString());
        // System.out.println(config);
        final JSONObject db = (JSONObject)config.get("database");
        //System.out.println(db.get("host")); // "localhost"
        //System.out.println(db.get("port")); // 5432
        
        final String actual = (String)db.get(EXAMPLE_KEY);
        //System.out.println(actual);
        if (actual.equals(EXAMPLE_KEY_EXPECTED_VALUE))
        {
          System.out.println("Got the expected value");
        }
        else
        {
          System.out.println("Did NOT get the expected value");
        }
        System.out.println(db.get("profilepath"));
      }
    }
  3. ingydotnet commented on Jul 3, 2026

    @ingydotnet
    Member

    @PH0lder Sorry just noticing this. This is really good feedback. Thanks!

    I'll try to split it into multiple issues here...

    While you wait, you might like reading https://yamlscript.org/blog/2025-06-04/load-and-compose-your-yaml-files/ for learning about some things you can do in YS YAML files.

    Closing this issue since Windows shared libs is to be working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions