본문 바로가기

문제 발생 및 해결

미해결 / Eclipse에서 PowerShell 실행 결과 보기

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.stream.Stream;

public class project {
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		String command = "powershell.exe  Get-Entity -Collection openrpa -Type workflow";
		// Executing the command
		Process powerShellProcess = Runtime.getRuntime().exec(command);
		// Getting the results
		powerShellProcess.getOutputStream().close();
		String line;
		System.out.println("Standard Output:");
		BufferedReader stdout = new BufferedReader(new InputStreamReader(powerShellProcess.getInputStream()));
		while ((line = stdout.readLine()) != null) {
			System.out.println(line);
		}
		stdout.close();
		System.out.println("Standard Error:");
		BufferedReader stderr = new BufferedReader(new InputStreamReader(powerShellProcess.getErrorStream()));
		while ((line = stderr.readLine()) != null) {
			System.out.println(line);
		}
		stderr.close();
		System.out.println("Done");
	}

}

참고 : stackoverflow.com/questions/29545611/executing-powershell-commands-in-java-program/29545926#29545926

 

문제 발생 : console창에서 한글 깨짐

 

1. eclipse 한글 깨짐 검색 (참고)

Window > Preferences 확인했더니 이미 UTF-8 설정 상태

 

2. eclipse console 한글 깨짐 검색 (참고)

Run > Run Configurations... > common > encoding 확인했더니 이것도 UTF-8 설정 되어 있음...

 

3. 해결 방법 찾지 못함. 그냥 workflow명을 영어로 수정하는 수밖에...