[JAVA] How to download and run a Jar package directly from the Maven repository with just the command line

Overview

--Download the Jar package directly from the Maven repository on the command line only --Run the downloaded Jar package on the command line

What are you happy about

--When you want to use tool-based Jar etc., you do not need to create POM.xml etc., you can complete it with just the command line

environment

How to do

Example: When you want to download and execute a package with groupId of org.riversun, artifactId of random-forest-codegen, and version 1.0.0.

** 1. Download the jar file to the current directory **

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

(If -Ddest is omitted, it will be downloaded to the local Maven repository **. M2 **.)

** 2. Run the jar **

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

(org.riversun.rfcode.RandomForestCodeGen is the main class you want to execute. If omitted, the default main class will be executed)

Summary

It is convenient because you can download the tool system that works with Jar alone directly from the Maven repository and execute it immediately.

Recommended Posts

How to download and run a Jar package directly from the Maven repository with just the command line
How to run a Kotlin Coroutine sample from the command line
I wanted to start the AP server and debug with just the Maven command
How to apply C code format from the command line
How to read a library from a JAR file with VS Code << How to not use Maven / Gradle >>
How to create a jar file or war file using the jar command
Create a jar file with the command
How to create a Maven repository for 2020
How to create a server executable JAR and WAR with Spring gradle
How to create a route directly from the URL you want to specify + α
Compile and run Java on the command line
How to build a Jenkins server with a Docker container on CentOS 7 of VirtualBox and access the Jenkins server from a local PC
How to run the SpringBoot app as a service
[Java] How to start a new line with StringBuilder
The story of pushing a Docker container to GitHub Package Registry and Docker Hub with GitHub Actions
Until you build a project described in scala with Maven and execute it with the scala command.
How to take a screenshot with the Android Studio emulator
How to use Maven to place resource files outside the JAR
How to create a form to select a date from the calendar
How to run React and Rails on the same server
A program that searches for a character string, and when the search character string is found, displays the character string from the beginning of the line to just before the search character string.
How to make Ubuntu a fixed IP address on the command line (explained as carefully as possible)
I tried to express the result of before and after of Date class with a number line
[Rails] How to introduce kaminari with Slim and change the design
To use the "java" command line tool ... How to avoid popping up
Create a flyway jar with maven and docker build (migrate) with docker-maven-plugin
How to run a job with docker login in AWS batch
How to open a script file from Ubuntu with VS code
[Swift5] How to communicate from ViewController to Model and pass a value
[Java] How to convert from String to Path type and get the path
I want to download a file on the Internet using Ruby and save it locally (with caution)
[Ruby] How to use is_a? Differences from kind_of? and instance_of ?. How to check the type and return a boolean value.
You cannot change the project facet version from a dynamic web module to x.x. How to deal with
Create command line app with maven
How to make a Maven project
Create a Maven project with a command
How to place geckodriver (Selenium WebDriver) on the path using Maven command
How to apply thymeleaf changes to the browser immediately with #Spring Boot + maven
How to interact with a server that does not crash the app
How to check before sending a message to the server with Spring Integration
Draw a bar graph and a line graph at the same time with MPAndroidChart
How to access Socket directly with the TCP function of Spring Integration
How to use args :, environment :, env_file: and .env files with docker-compose command
How to compare only the time with Rails (from what time to what time, something like)
[Rails] How to create a table, add a column, and change the column type
How to SSH into Ubuntu from a terminal with public key authentication
How to display the text entered in text_area in Rails with line breaks
How to make an app with a plugin mechanism [C # and Java]
[Ruby] I want to make an array from a character string with the split method. And vice versa.