Jar

main

jar runner for macos
SwiftPackageRepository/Jar.swift

Jar.swift

jar runner for macos

Jar.swift is created and maintaned with ❥ by Sascha Muellner.


Swift codecov License Version SPM compatible README

What?

This is a Swift package with support for macOS that allows to start Java Jar's with the default or a custom JVM.

Requirements

The latest version of Jar requires:

  • Swift 5+
  • macOS 10.12+
  • Xcode 11+

Installation

Swift Package Manager

Using SPM add the following to your dependencies

'Jar', 'main', 'https://github.com/SwiftPackageRepository/Jar.swift.git'

How to use?

Run a remote Jar

For running a remote Jar the only requirement is creating a Jar reference with the origin of the Jar and the locale name for the cache. After creating a Java runtime reference the Jar can be just "executed".

    let jar = Jar(origin: URL(string: "https://domain.com/your.jar"), filename: "your.jar")
    let java = Java()
    let (result, error) = java.run(jar: jar, args: [])

or more complete for running the HelloWorld.jar:

import Foundation
import Jar

struct HelloWorld {
    static func run() {
        let url = URL(string: "https://github.com/slaminatl/Helloworld/raw/master/out/artifacts/HelloWorld_jar/HelloWorld.jar")!
        let jar = Jar(origin: url, filename: "helloworld.jar")
        let java = Java()
        let (result, error) = java.run(jar: jar, args: [])
        if let result = result {
            print(result)
        } else if let error = error {
            print(error.localizedDescription)
        }
    }
}

Description

  • Swift Tools 5.5.0
View More Packages from this Author

Dependencies

  • None
Last updated: Mon Oct 21 2024 17:02:50 GMT-0900 (Hawaii-Aleutian Daylight Time)