Swift/Java people - This may be a stupid question.

The W3C's epub validator is a jar file that can be executed from the command line.

Is this something that can be easily wrapped in a small swift app? I.e. can you call a jar file from a swift Mac app and pipe the output. Do you need to install Java on your Mac to do so?

I clearly haven't thought about this much but woke up wondering if I could replace this use of Docker and remembered @airspeedswift 's session at Server Side 2024.

@dimsumthinking I don't know anything about the Swift specifics of executing processes and capturing their output, but it's common for Java apps to bundle a JRE. You would need to bundle a JRE that is appropriate for each platform you intend the app to run on and figure out which one to invoke. I'm not sure though how that would play with Apple's sandboxing. Would Apple block the Java process from executing or at least require separate permission?
@hosierdavid @dimsumthinking You should be able to bundle the JRE and sign it as a helper executable. The app should be able to execute it as a subprocess with no problem. It’ll be trapped in the app’s sandbox without jumping through a bunch more hoops, but that should be okay for a validator?

@dimsumthinking it used to be possible in project builder in earlier OSX times.

The way a bundled app is executed and can bundle whole runtimes (swift early days used to bundle the whole shebang), I would assume it is indeed possible. The app bundle rules haven’t changed much.

But I have an inkling it wouldn’t work without a more permissive setting for XProtect.

Something like https://medium.com/swift2go/embedding-python-interpreter-inside-a-macos-app-and-publish-to-app-store-successfully-309be9fb96a5

Or

https://www.balthisar.com/blog/bundle-the-jre/

Might give you early pointers

Embedding a Python interpreter inside a MacOS / iOS app, and publishing to the App Store…

The struggle was real

Medium