Posted August 2, 20214 yr I am attempting to use the javax-usb API in my client only mod. I've got everything working in the dev environment, but it has this requirement that it needs a properties file in the "root of the classpath." It uses this line to pull that file: UsbHostManager.class.getClassLoader().getResourceAsStream(JAVAX_USB_PROPERTIES_FILE); where JAVAX_USB_PROPERTIES_FILE is just the name of the file it is looking for without any subdirectory. The relevant package is shadowed into the jar and the properties file is at the root of the jar. Everything looks right to me, but it can't find the file. I also tried running MY_MOD_CLASS.class.getClassLoader().getResourceAsStream(JAVAX_USB_PROPERTIES_FILE); in case the shadowing had messed something up. It still comes back null. I've been struggling with this for a while. My only conclusion is that getResourceAsStream must not search the way I thought it did. I'd appreciate any direction you can give. Thanks.
August 3, 20214 yr Author I figured this out. Turns out, it's not really Forge related, but I'll leave the answer here in case it helps someone else out. The package is javax.usb. The file is javax.usb.properties. I was having some issues so when I shadowed in the package, so I told shadow to relocate it to com.github.theredwagoneer.javax.usb. What I didn't know is that besides relocating actual package references, shadow actually relocated strings that match the package pattern. However, it didn't rename resource filenames or resource file contents. So the mod was looking for com.github.theredwagoneer.javax.usb.properties, but all that was there was javax.usb.properties. The string inside the file needed to change too. Relocated those manually. All works now.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.