java命令有效,但javac命令不起作用?

时间:2017-06-19 03:01:26

标签: java

我已经下载了jdk 1.8.0_131

当我打开命令提示符并编写以下命令时 - java -version它给我输出

java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

但是当我编写以下命令时:javac -version它给我输出

'javac' is not recognized as an internal or external command,
operable program or batch file.

我已将系统变量路径编辑为 - C:\ Progra~1 \ Java \ jdk1.8.0_131 \ bin;

当我执行以下命令时:“C:\ Program Files \ Java \ jdk1.8.0_131 \ bin \ javac”-version

它给了我输出:

javac 1.8.0_131

所以我知道我已经安装了正确的java版本

我还检查了上面的文件夹,并在那里找到了一个javac.exe。请帮忙。

编辑:

我终于解决了这个问题。我正在做的是编辑“Path”变量,当我不得不做一个名为“PATH”的新变量和以下细节时:

Variable name  : PATH
Variable value : c:\Program Files\Java\jdk1.8.0_xx\bin;[Existing Entries...

2 个答案:

答案 0 :(得分:1)

您是否尝试重新启动“cmd.exe”,因为将bin目录添加到PATH?

如果您确认您的PATH包含了java bin目录,并且您可以在该位置看到“javac.exe”二进制文件,那么所有这些都应该正确设置。

答案 1 :(得分:0)

在Windows中,您需要将require "db" require "sqlite3" module Project Migrations = [] of Migration class Migration def initialize(@version : Int) end # Registers a callback that will be called when the `up`-method is called. # The callback must return either `true` for a successful migration, # or `false` for a failed migration. If an `up` migration has # failed, the `down` migration will be called to restore the database # back to its previous state. # The callback will receive an instance of `DB::Database` # # Example: # # ``` # migration = Migration.new(1) # # migration.register_up |db| do # # Advance migration # end # # migration.register_down |db| do # # Recede migration # end # ``` def register_up(&block : (DB::Database) -> Bool) @up = block end # Registers a callback that will be called when the `down`-method is called. # See the `register_up` method for more information def register_down(&block : (DB::Database) -> Bool) @down = block end # Advances DB to the next version def up(conn : DB::Database) result = @up.call(conn) unless result # Failed migration, rollback @down.call(conn) raise Exception.new(`Failed to migrate database to version: #{@version}. Rolling back.`) end end # Recedes DB to the previous version def down(conn : DB::Database) result = @down.call(conn) unless result # Failed migration, rollback @up.call(conn) raise Exception.new(`Failed to migrate database to version: #{@version - 1}. Rolling back.`) end end end end 的路径添加到jdk_your_version/bin变量。将此行添加到PATH

PATH

保存。然后重新启动C:\Progra~1\Java\jdk1.8.0_131\bin; ,因为它不会自动更新open cmd的路径。然后您应该能够看到CMD正在运行:

javac