3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

コマンドラインだけでMavenリポジトリから直接Jarパッケージをダウンロードして実行する方法

Posted at

概要

  • コマンドラインのみでMavenリポジトリから直接Jarパッケージをダウンロードします
  • ダウンロードしたJarパッケージをコマンドライン上で実行します

何が嬉しいか

  • ツール系のJarなどを使いたいとき、POM.xmlなど作成不要で、コマンドラインだけで完結できる

環境

やりかた

例:groupIdがorg.riversun、artifactIdがrandom-forest-codegen、versionが1.0.0のパッケージをダウンロードしてきて実行したいとき

1.現在のディレクトリにjarファイルをダウンロードする

mvn dependency:get -Dartifact=org.riversun:random-forest-codegen:1.0.0 -Ddest=./

(-Ddestを省略すると、ローカルのMavenリポジトリ**.m2**にダウンロードされる。)

2.jarを実行する

java -cp random-forest-codegen-1.0.0.jar org.riversun.rfcode.RandomForestCodeGen

(org.riversun.rfcode.RandomForestCodeGenは実行したいメインクラス。省略するとデフォルト指定のメインクラスが実行される)

まとめ

Jar単体でも動作するツール系をMavenリポジトリから直接ダウンロードし、すぐ実行できて便利です

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?