IntelliJ IDEA 中的Terminal中模拟实现通过命令行执行程序
terminal
The new Windows Terminal and the original Windows console host, all in the same place!
项目地址:https://gitcode.com/gh_mirrors/term/terminal
免费下载资源
·
1.代码及代码结构示例
结构:
代码示例:
package chapter6;
public class Demo6_6 {
public static void main(String args[]){
System.out.println("1. 算法计算开始:");
try{
int x = Integer.parseInt(args[0]);
int y = Integer.parseInt(args[1]);
System.out.println("2. 除法计算:" + (x/y));
// 异常产生之后的语句将不再执行,此处在try中产生异常,所以下面的语句将不会执行
System.out.println("除法计算之后的语句,若产生异常则不会输出本句");
} catch (ArithmeticException e){
e.printStackTrace();
}finally {
System.out.println("****无论是否产生异常都会输出****");
}
System.out.println("3. 除法计算结束。");
}
}
2.简要分析
如果我们直接执行上述程序,无法给Demo6_6中的“main”传入args[]参数,于是我们在IDEA中模拟命令行该程序。
(1)编译程序;
选择build---BuildProjet编译修改过的文件,或者选择Rebuild Project重新编译整个项目。注意观察生成的class文件。
(2)点击下方的Terminal选项,出现类似“cmd”的命令行窗口。
我们执行Demo6_6经过编译生成的Demo6_6.class文件:
如下图分别对应不传参与传参的输入方法:
命令
java -cp E:\JavaProject\IdeaProjects\FirstLineJava\out\production\FirstLineJava chapter6.Demo6_6 10 2
中的“-cp” 标识class文件所在的路径, “chapter.demo6_6”表示class“Demo6_6”属于package“chapter6”,后面的10与2为传入的参数。
GitHub 加速计划 / term / terminal
94.53 K
8.17 K
下载
The new Windows Terminal and the original Windows console host, all in the same place!
最近提交(Master分支:2 个月前 )
d04381ec
"HighContrast" is not a possible requested theme. So `_UpdateBackgroundForMica()` would force the settings UI to be light or dark. To fix this, we just check if we're in high contrast mode and, if so, we don't bother setting the requested theme. 7 天前
e83434ff
Turns out that having the styles for the KeyChordText and ParsedCommandLineText be empty for high contrast mode caused the issue. Since we're already using theme resources for the colors, we automatically adjust properly to whatever the high contrast theme is (Thanks XAML!).
Bonus points:
- we didn't need the theme dictionaries anymore, so I just moved them to the ResourceDictionary directly
- ParsedCommandLineTextBlockStyle isn't used. So I removed it altogether.
Validated command palette with multiple high contrast themes. See PR thread for demo.
Closes #17914 7 天前
更多推荐
已为社区贡献2条内容
所有评论(0)