How to integrate batch script multiple selections into JAVA GUI?

后端 未结 2 1761
梦如初夏
梦如初夏 2020-12-21 18:28

EDITED 27/7/2014

PLEASE READ CAREFULLY AS MY QUESTION IS A BIT COMPLICATED

Hi, I wanted to do a coding whereby it involves a JAVA GUI, batch

相关标签:
2条回答
  • 2020-12-21 18:35

    You can write a Java program and use Scanner to take input from user:

    Scanner in = new Scanner(System.in);

    You can invoke this program from a batch file using following command:

    @ECHO OFF
    

    %JAVA_HOME%\bin\java MyClass

    Have given you pointers and leave rest to you to figure out.

    Cheers !!

    0 讨论(0)
  • 2020-12-21 18:47

    Change this line:

    if %choices% equ 6 set choices=1,2,3,4,5
    

    by this one:

    if "%choices:6=%" neq "%choices%" set choices=1,2,3,4,5
    

    I also suggest you to use arrays.

    EDIT: Example added

    @echo off
    
    :getOptions
    set "choices="
    set /P "choices=Choices: "
    if not defined choices goto :EOF
    if "%choices:6=%" neq "%choices%" set choices=1,2,3,4,5,6
    echo Execute: %choices%
    goto getOptions
    

    Example output:

    C:\> test.bat
    Choices: 1,3,5
    Execute: 1,3,5
    Choices: 1,2,4,6
    Execute: 1,2,3,4,5,6
    Choices: 1,6
    Execute: 1,2,3,4,5,6
    Choices:
    

    EDIT: I obviously made the error of also include 6 in the replacement, but you get the point!

    0 讨论(0)
提交回复
热议问题