Swiftpack.co - SwiftPackageRepository/Jar.swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by SwiftPackageRepository.
SwiftPackageRepository/Jar.swift 0.0.2
jar runner for macos
⭐️ 1
🕓 2 years ago
macOS
.package(url: "https://github.com/SwiftPackageRepository/Jar.swift.git", from: "0.0.2")

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)
        }
    }
}

GitHub

link
Stars: 1
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics