https://github.com/swiftpackagerepository/jar.swift
jar runner for macos
https://github.com/swiftpackagerepository/jar.swift
Last synced: 5 months ago
JSON representation
jar runner for macos
- Host: GitHub
- URL: https://github.com/swiftpackagerepository/jar.swift
- Owner: SwiftPackageRepository
- License: mit
- Created: 2021-11-07T14:39:45.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-17T20:36:59.000Z (over 3 years ago)
- Last Synced: 2025-01-28T19:49:47.270Z (5 months ago)
- Language: Swift
- Size: 39.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Jar.swift
## jar runner for macos
Jar.swift is **created and maintaned with ❥** by Sascha Muellner.
---
[](https://github.com/SwiftPackageRepository/Jar.swift/actions?query=workflow%3ASwift)
[](https://codecov.io/gh/SwiftPackageRepository/Jar.swift)
[](https://github.com/SwiftPackageRepository/Jar.swift/blob/main/LICENSE)

[](https://swiftpackageindex.com/SwiftPackageRepository/Jar.swift)
[](https://swiftpackageindex.com/SwiftPackageRepository/Jar.swift)
[](https://github.com/apple/swift-package-manager)
[](https://SwiftPackageRepository.github.io/Jar.swift)## 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".```swift
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:
```swift
import Foundation
import Jarstruct 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)
}
}
}
```