在Windows 10命令提示符中运行Java程序

时间:2015-09-03 01:20:58

标签: java windows

我最近在运行Windows 10的计算机上下载了Java SDK 8.0。但是,当我在Internet上查看如何在Windows 10命令提示符中使用Java时,我只能获得 var vm = this; vm.dashboardGlobals = globalContainer.dashboardGlobals; var dataFactory = new abstractDataFactory("/odata/ProjectList"); var projectController = new abstractDataFactory("/Projects/ChangeCurrentProject") // load up projectDashboardDTO vm.projectList = []; . . . dataFactory.getList("") // no parameters .success(function (result) { vm.projectList = result.value; vm.dashboardGlobals.projectList = result.value; vm.selectProjectPlaceholder = "Select a project . . . " 命令在提示中工作。当我尝试运行我的程序时,命令提示符说它找不到javac文件。有谁知道如何让Java在Windows 10中运行? (我使用的是x86版本的Java。)

2 个答案:

答案 0 :(得分:1)

打开命令提示符cmd并输入where java,这将输出java可执行文件的位置,然后您可以转到System Propreties>Advanced>Environement Variables> (右键单击计算机并单击Propreties) 并将where java输出添加到用{em>分号 PATH分隔的;变量

答案 1 :(得分:0)

Java实际上不必安装 。您可以运行任何可用的Java。

这对于从网络共享运行Java有用。

尝试通过完全限定来运行java.exe程序。如果它以这种方式运行,则问题出在PATH上。

为了说明你可以通过限定运行任何Java,我安装了9个JDK和1个JRE:

  • 32位JDK:版本1.4,5,6,7和8
  • 64位JDK:版本5,6,7和8
  • 32位JRE:版本8

从单个命令提示符窗口复制:

C:\>"C:\prog\java32\jdk1.4.2_19\bin\java.exe" -version
java version "1.4.2_19"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_19-b04)
Java HotSpot(TM) Client VM (build 1.4.2_19-b04, mixed mode)

C:\>"C:\prog\java32\jdk1.5.0_22\bin\java.exe" -version
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) Client VM (build 1.5.0_22-b03, mixed mode)

C:\>"C:\prog\java32\jdk1.6.0_45\bin\java.exe" -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) Client VM (build 20.45-b01, mixed mode, sharing)

C:\>"C:\prog\java32\jdk1.7.0_79\bin\java.exe" -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) Client VM (build 24.79-b02, mixed mode, sharing)

C:\>"C:\prog\java32\jdk1.8.0_51\bin\java.exe" -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) Client VM (build 25.51-b03, mixed mode)

C:\>"C:\prog\java64\jdk1.5.0_22\bin\java.exe" -version
java version "1.5.0_22"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03)
Java HotSpot(TM) 64-Bit Server VM (build 1.5.0_22-b03, mixed mode)

C:\>"C:\prog\java64\jdk1.6.0_45\bin\java.exe" -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

C:\>"C:\prog\java64\jdk1.7.0_79\bin\java.exe" -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

C:\>"C:\prog\java64\jdk1.8.0_51\bin\java.exe" -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

C:\>"C:\Program Files (x86)\Java\jre1.8.0_51\bin\java.exe" -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) Client VM (build 25.51-b03, mixed mode, sharing)