{"id":15044042,"url":"https://github.com/terl/resource-loader","last_synced_at":"2025-04-10T00:41:54.613Z","repository":{"id":43817328,"uuid":"201693249","full_name":"terl/resource-loader","owner":"terl","description":"Getting files out of a JAR or loading a shared library is difficult. We made it easy.","archived":false,"fork":false,"pushed_at":"2024-03-18T15:47:34.000Z","size":5793,"stargazers_count":21,"open_issues_count":8,"forks_count":11,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-10T00:41:47.806Z","etag":null,"topics":["jar","java","java-8","library","loading","shared-library"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/terl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-10T23:22:16.000Z","updated_at":"2025-01-16T08:05:44.000Z","dependencies_parsed_at":"2022-09-15T02:12:14.072Z","dependency_job_id":null,"html_url":"https://github.com/terl/resource-loader","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terl%2Fresource-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terl%2Fresource-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terl%2Fresource-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/terl%2Fresource-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/terl","download_url":"https://codeload.github.com/terl/resource-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137999,"owners_count":21053775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jar","java","java-8","library","loading","shared-library"],"created_at":"2024-09-24T20:49:59.630Z","updated_at":"2025-04-10T00:41:54.599Z","avatar_url":"https://github.com/terl.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cimg width=\"130\" style=\"display: inline;\" src=\"https://filedn.com/lssh2fV92SE8dRT5CWJvvSy/libly/resource-loader.png\" /\u003e\n\n\n# Resource Loader\n\nResource Loader gives you the functions to load `resource` files even if you are loading from inside a JARs or outside a JAR. Resource Loader also supports loading shared libraries through `SharedLibraryLoader`.\n\n[![Checks](https://github.com/terl/resource-loader/actions/workflows/primary.yml/badge.svg)](https://github.com/terl/resource-loader/actions/workflows/primary.yml)\n\n## Installation\n\nThis is how to install the library in Gradle based projects.\n\n```groovy\n// Top-level build.gradle\nrepositories {\n    // ...\n    mavenCentral()\n}\n\ndependencies {\n    // ...\n    implementation 'com.goterl:resource-loader:2.0.2' // Add this line\n}\n```\n\n\n## Usage\n\n### Loading a file\n\nLet's say you have a file in your `resources` folder called `test1.txt`. To get it you simply do the following:\n\n```java\nFile file = FileLoader.get().load(\"test1.txt\");\n```\n\nResource Loader can also load from paths and directories. Just make sure the top level directory name is somewhat unique:\n\n```java\n// The following loads test1.txt from the resources folder\n// even if you supply a nested path.\nFile file2 = FileLoader.get().load(\"a_unique_top_level_folder/path/test1.txt\");\n\n// You can even load whole directories.\nFile dir = FileLoader.get().load(\"a_unique_top_level_folder/directory\"); \n```\n\n### Loading a shared library\nLoading a shared library is just as simple. You can load one by using `loadSystemLibrary` which loads a shared library if it is already installed on the system.\n\n```java\n// Load from the system\nSharedLibraryLoader.get().loadSystemLibrary(\"hydrogen\", Hydrogen.class);\n```\n\nOr you can use `load` which loads a shared library even if it is bundled inside a JAR or not.\n\n```java\n// Load from the system\nSharedLibraryLoader.get().load(\"hydrogen\", Hydrogen.class);\n```\n\n## What problem does Resource Loader solve?\nConsider the scenario. You have a project with some files in the `resource` folder. You're loading those files using `getResourceAsStream` and it's working when you test it locally. But when you go to package the project as a JAR and then run it, it fails!\n\nResource Loader provides developers with a fool-proof way of loading files inside or outside JARs by loading the files in a temporary folder that is deleted when the corresponding Java process that created that temp process has been destroyed.\n\nHere are some features of Resource Loader:\n \n- [x] Can be used in Android _**and**_ Java projects.\n- [x] Load from _nested_ JARs up to 20 levels deep.\n- [x] Resource Loader works with shared libraries (`.dll`, `.so`, `.dylib`) and can initialise them.\n- [x] Can extract regular files from the `resources` folder.\n- [x] Simple include this library and use the `.load` functions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterl%2Fresource-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fterl%2Fresource-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fterl%2Fresource-loader/lists"}