“Cara menjalankan java di cmd” Kode Jawaban

Java Run CMD

public void excCommand(String new_dir){
    Runtime rt = Runtime.getRuntime();
    try {
        rt.exec(new String[]{"cmd.exe","/c","start"});

    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

Java Run CMD


import java.io.*;

public class CmdTest {
    public static void main(String[] args) throws Exception {
        ProcessBuilder builder = new ProcessBuilder(
            "cmd.exe", "/c", "cd \"C:\\Program Files\\Microsoft SQL Server\" && dir");
        builder.redirectErrorStream(true);
        Process p = builder.start();
        BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String line;
        while (true) {
            line = r.readLine();
            if (line == null) { break; }
            System.out.println(line);
        }
    }
}

Cruel Cod

cara menjalankan file java

javac <yourfilename>.java
after that do:
java <yourfilename>
Relieved Ray

Cara menjalankan java di cmd

// i have a file name : demo.java
public class demo{
  public static void main(String[]args){
    System.out.println("hello world");
  }
}
//open cmd or terminal on folder and then : java demo.java 
Itchy Iguana

Jawaban yang mirip dengan “Cara menjalankan java di cmd”

Pertanyaan yang mirip dengan “Cara menjalankan java di cmd”

Lebih banyak jawaban terkait untuk “Cara menjalankan java di cmd” di Java

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya