Paper on classpath instead of run via -jar?


I’m experimenting using to run paper and build plugins.

I’m curious to understand what paper is relying on that makes it that with java 8 it is fine to put paper jar on --classpath and specify a main class, but with Java 9 and above it seems I must run it with java -jar otherwise I get the dreaded: Unable to retrieve Instrumentation API to add Paper jar to ClassPath

Anyone knows how that is ?

Reason I like to avoid it is that in jbang I avoid using -jar as it does not allow to easily extend the classpath (without hacks) - but now it seems like paper does do some "thing’; which then makes --classpath impossible.

with hope,

ah, interesting - so its because of Launcher-Agent-Class: io.papermc.paperclip.Agent.


I could make that work nicely in jbang if the agent would be available as a jar in a maven repo - is there a maven repository for any of papermc’s jar ? Did not find them in maven central.

No, we cannot ship those jars due to legal reasons, EULA, DMCA, etc, etc, hence paperclip
Once the jar has been ran, there will be a patched jar in the cache folder which doesn’t need an agent to start, afaik, the agent can also be passed in as a flag

understand about the legal reasons. makes sense.

Which flag do you see letting you specify a agent class ? I only know about --javaagent that requires a jar.

An --javaagent does not work as the paper jar itself does not contain a PreMain-class manifest entry. If it did I think it would work; but not in its current form.

This is easy to fix, I created an issue for it. I’ll push it up after work today.

You can also run paperclip once: java -jar paperclip.jar -Dpaperclip.patchonly=true and it’ll produce a server jar you can use.