在cmd中Java可以运行,javac不能运行
我的环境变量是这样的Java_home=C:\ProgramFiles\Java\jdk1.8.0_144;Path="C:\ProgramFiles\Java\jdk1...
我的环境变量是这样的
Java_home=C:\Program Files\Java\jdk1.8.0_144;
Path="C:\ProgramFiles\Java\jdk1.8.0_144\bin";%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files (x86)\Skype\Phone\;C:\Program Files (x86)\QuickTime\QTSystem\
Classpath=.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar; 展开
Java_home=C:\Program Files\Java\jdk1.8.0_144;
Path="C:\ProgramFiles\Java\jdk1.8.0_144\bin";%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files (x86)\Skype\Phone\;C:\Program Files (x86)\QuickTime\QTSystem\
Classpath=.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar; 展开
展开全部
环境变量错误了,自己重新配置下吧。
Set fso = CreateObject("Scripting.FileSystemObject")
Set w = createobject("wscript.shell")
sub error()
msgbox "该目录不是JDK安装目录!",16 + 4096,"设置JDK环境变量(By无良风筝Fly)"
main()
end sub
'==================自动查找JDK路径(在Program Files文件夹中)==================
function findJava()
dim java_path
windows_disk = fso.getdrivename(fso.getspecialfolder(WindowsFolder))
if fso.folderexists(windows_disk&"\Program Files\Java\") then
set java_path = fso.getfolder("C:\Program Files\Java\")
elseif fso.folderexists(windows_disk&"\Program Files (x86)\Java\") then
set java_path = fso.getfolder("C:\Program Files (x86)\Java\")
end if
For Each folder In java_path.subfolders
If InStr(1, folder, "jdk") > 0 Then
if fso.fileexists(folder&"\bin\java.exe") then
findJava = folder
end if
end if
next
end function
sub main()
folder = findJava()
java = folder
autoSet = true
if folder = "" then
Set objShell = CreateObject("Shell.Application")
Set folder = objShell.BrowseForFolder(0,"选择JDK的安装目录:"&chr(13)&"By无良风筝Fly"&chr(13)&"设置环境变量需要一些时间,请耐心等待",0,17)
if folder is nothing then
wscript.quit
end if
if folder.self.path = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" then
error()
end if
set java = fso.getfolder(folder.self.path)
autoSet = false
end if
if fso.fileexists(java&"\bin\java.exe") then
java_home = w.Environment("user").Item("java_home")
if java_home <> "" then
msgbox "已经不需要再设置了!",48 + 4096,"设置JDK环境变量(By无良风筝Fly)"
else
if autoSet then
msgbox "已找到JDK目录"&chr(13)&"将在点击确定后进行设置,可能需要一些时间",64,"设置JDK环境变量(By无良风筝Fly)"
end if
w.Environment("user").Item("java_home") = java
w.Environment("user").Item("Path") = w.Environment("user").Item("Path")&"%java_home%\bin"
w.Environment("user").Item("classpath") = w.Environment("user").Item("classpath")&";.;%java_home%\lib\tools.jar;%java_home%\lib\dt.jar"
msgbox "环境变量设置完毕!",64 + 4096,"设置JDK环境变量(By无良风筝Fly)"
end if
else
error()
end if
end sub
main()
把有关jdk配置的删除,把上面的代码保存成".vbs"后缀的文件。运行一下就行了。
追问
好了行了。谢谢你啊
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询