英文:
How can I check the installed version of dotnet core using Java
问题
我正在编写一个Java应用程序,需要检查主机上安装的dotnet
核心版本。我首先需要检查我的主机是Windows
还是Linux
,然后检查dotnet
版本。在Java中是否有更简单的方法?
英文:
I am writing a java application where I need to check what is the installed version of dotnet
core on the host machine. I need to first check whether my host machine is windows
or Linux
and then check the dotnet
version. Is there a simpler way to do it in Java?
答案1
得分: 3
<br>
with
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("dotnet --version");
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
英文:
<br>
with
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec("dotnet --version");
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
you will get the version of your installed dotnet version.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论