Running java project in command line with user input

P.Smith

I have a java project which I'm running in the command line. I have created a .bat file to run the project. However my java project must take in 4 arguments before it starts running which works like this in my .bat file....

@echo off
pushd %~dp0
java -jar dist/prog.jar 5 6 7 3

pause

(5 6 7 3 being the arguments passed to String[] args)

However, I do not want to input the specific arguments to be passed to String[] args in the .bat file, I want it to be passed by user input so that I can enter in different values as my arguments in the command line each time I run it. How can I do this?

Jan

You can use % replacements to pass in the parameters given to the .cmd

@echo off
pushd %~dp0
REM %* forwards all parameters
java -jar dist/Election_real.jar %*
pause

And then call yourcmd.cmd 5 6 7 8

If you want to ask for these parameters, you'd go

@echo off
pushd %~dp0
set /p nr1=Enter Nr1:
set /p nr2=Enter Nr2:
set /p nr3=Enter Nr3:
set /p nr4=Enter Nr4: 
java -jar dist/Election_real.jar %nr1% %nr2% %nr3% %nr4%
pause

Este artigo é coletado da Internet.

Se houver alguma infração, entre em [email protected] Delete.

editar em
0

deixe-me dizer algumas palavras

0comentários
loginDepois de participar da revisão

Artigos relacionados

R script with user input from command line

Run Java Maven project with Linux command line

script for Running MPI program with three input files as command line arguments

How to get name of user account running a process on Windows command line?

Reading user command line input with PHP with readline, but bash is not default shell

A single line command to take and print the user's input

Running Python in command line

ClassNotFoundException for mixed java and kotlin code when running from command line

Running java programs from the command line on Windows 10

User input a word then print letters of the word on a new line for java

Running a complex command line in python

Running php via command line

Adding command line arguments to project

How to get input from user and pass it to an interactive command line program triggered by subprocess call in python?

Choose Python classes to instantiate at runtime based on either user input or on command line parameters

User Input of sentence in Java

Running tsc from the Windows command line

How to run testng appium-java maven project build in Intellij idea from command line?

vscode command line : open a file of an opened project

Pycharm - command line to build cache/index for a project

Deploy SSAS Project using TFS Command Line

Deploy SSIS Project using TFS Command Line

How to debug command line input in WebStorm

Extracting the user-written command line for a function

Change user password with one command line

Why is the line number appended to a cucumber command line user variable?

How to pass command line arument in spring boot app when running from command line

Errors When Running Java from Command Prompt

Package not found while running Verticle from command line

TOP lista

  1. 1

    R Shiny: use HTML em funções (como textInput, checkboxGroupInput)

  2. 2

    O Chromium e o Firefox exibem as cores de maneira diferente e não sei qual deles está fazendo certo

  3. 3

    Como assinar digitalmente um documento PDF com assinatura e texto visíveis usando Java

  4. 4

    R Folheto. Dados de pontos de grupo em células para resumir muitos pontos de dados

  5. 5

    Gerenciar recurso shake de Windows Aero com barra de título personalizado

  6. 6

    Como obter dados API adequados para o aplicativo angular?

  7. 7

    UITextView não está exibindo texto longo

  8. 8

    Por que meus intervalos de confiança de 95% da minha regressão multivariada estão sendo plotados como uma linha de loess?

  9. 9

    Acessando relatório de campanhas na AdMob usando a API do Adsense

  10. 10

    Usando o plug-in Platform.js do Google

  11. 11

    Como posso modificar esse algoritmo de linha de visada para aceitar raios que passam pelos cantos?

  12. 12

    Dependência circular de diálogo personalizado

  13. 13

    Coloque uma caixa de texto HTML em uma imagem em uma posição fixa para site para desktop e celular

  14. 14

    iOS: como adicionar sombra projetada e sombra de traço no UIView?

  15. 15

    Como usar a caixa de diálogo de seleção de nomes com VBA para enviar e-mail para mais de um destinatário?

  16. 16

    Tabela CSS: barra de rolagem para a primeira coluna e largura automática para a coluna restante

  17. 17

    How to create dynamic navigation menu select from database using Codeigniter?

  18. 18

    Converter valores de linha SQL em colunas

  19. 19

    ChartJS, várias linhas no rótulo do gráfico de barras

  20. 20

    用@StyleableRes注释的getStyledAttributes。禁止警告

  21. 21

    não é possível adicionar dependência para com.google.android.gms.tasks.OnSuccessListener

quentelabel

Arquivo