У меня есть следующий код:
public static void main(String[] args) {
String prop1 = System.getProperty("test.prop", "missing");
System.out.println("test.prop: " + prop1);
String prop2 = System.getProperty("otherprop", "missing");
System.out.println("otherprop: " + prop2);
String cmd = System.getProperty("sun.java.command");
System.out.println("cmd: " + cmd);
}
Я вызываю встроенную банку с помощью PowerShell:
> java -jar TestApp.jar -Dtest.prop=value1 -Dotherprop=value2
test.prop: missing
otherprop: missing
cmd: TestApp.jar -Dtest .prop=value1 -Dotherprop=value2
> java -Dtest.prop=value1 -Dotherprop=value2 -jar TestApp.jar
Error: Could not find or load main class .prop=value1