Windows 명령 프롬프트에서 javac가 작동하지 않습니다
javac
Windows 명령 프롬프트와 함께 사용하려고하는데 작동하지 않습니다.
환경 변수 "C:\Program Files\Java\jdk1.6.0_16\bin\"
끝에 디렉토리 를 추가하면 명령이 정상적으로 작동하지만 사용 하면 다음과 같은 오류가 발생합니다.PATH
java
javac
'javac'는 내부 또는 외부 명령, 작동 가능한 프로그램 또는 배치 파일로 인식되지 않습니다.
명령 프롬프트가 열려있는 동안 제어판에서 추가 한 경우 현재 명령 프롬프트에 영향을 미치지 않습니다. 종료하고 다시 열거 나 간단하게 수행해야합니다.
set "path=%path%;c:\program files\java\jdk1.6.0_16\bin"
확인하여 다음을 실행하십시오.
echo %path%
명령 프롬프트에서 그 내용을 알려주십시오.
그렇지 않으면 다음을 시도하여 해당 디렉토리에 javac 가 있는지 확인하십시오 .
"c:\program files\java\jdk1.6.0_16\bin\javac.exe"
명령 프롬프트에서. 당신은 또한 말할 수 있는 명령으로 사용되는 실행 파일 (있는 경우) :
for %i in (javac.exe) do @echo %~$PATH:i
이것은 일부 UNIX 유형 운영 체제 의 which
및 / 또는 whence
명령 과 유사한 깔끔한 트릭 입니다.
Windows OS는 현재 디렉토리와 PATH 환경 변수에 나열된 디렉토리에서 실행 가능한 프로그램을 검색합니다. JDK의 프로그램 (예 : Java 컴파일러 javac.exe 및 Java 런타임 java.exe)은 "\ bin"디렉토리에 있습니다 (여기서 JDK 설치 디렉토리 (예 : C : \ Program Files \ Java \ jdk1.8.0_xx)). PATH에 "\ bin"디렉토리를 포함시켜야합니다.
Windows XP / Vista / 7 / 8에서 PATH 환경 변수를 편집하려면
제어판 ⇒ 시스템 ⇒ 고급 시스템 설정
"고급"탭으로 전환 ⇒ 환경 변수
"시스템 변수"에서 아래로 스크롤하여 "PATH"를 선택합니다. ⇒ 편집
((이제 진행하기 전에 다음 3 번을 읽으 십시오. 실행 취소 없음 ))
"가변 값"필드에서 "c : \ Program Files \ Java \ jdk1.8.0_xx \ bin"INSERT (xx를 업그레이드 번호로 바꾸고 이것이 JDK의 바이너리 디렉토리임을 확인하십시오 !!!) 디렉토리 뒤에 세미콜론 (;)을 붙여 JDK의 이진 디렉토리를 나머지 기존 디렉토리와 구분합니다. 기존 항목을 삭제하지 마십시오. 그렇지 않으면 일부 기존 응용 프로그램이 실행되지 않을 수 있습니다.
Variable name : PATH
Variable value : c:\Program Files\Java\jdk1.8.0_xx\bin;[existing entries...]
After a long Google, I came to know that javac.exe will be inside JDK(C:\Program Files\Java\jdk(version number)\bin) not inside JRE (C:\Program Files (x86)\Java\jre7\bin) "JRE doesn't come with a compiler. It(JRE) is simply a java runtime environment. What you need is the Java development kit." in order to use compiler javac
javac will not work if you are pointing bin inside jre
In order to use javac in cmd , JDK must be installed in your system...
For javac path
path = C:\Program Files (x86)\Java\jre7\bin this is wrong
path = C:\Program Files\Java\jdk(version number)\bin this is correct
Make sure that "javac.exe" is inside your "C:\Program Files\Java\jdk(version number)\bin"
Don't get confused with JRE and JDK both are totally different
if you don't have JDK pls download from this link http://www.oracle.com/technetwork/java/javase/downloads/index.html
reference thread for JDK VS JRE What is the difference between JDK and JRE?
I know this may not be your specific error, but I once had a leading space in my path and java would work but javac would not.
For what it's worth, I offer the sage advice: "Examine your Path closely".
Try the solutions here: http://techdem.centerkey.com/2009/05/javahome-command-script.html
These are much more robust to change -- like when you upgrade the JDK or JRE, since there is no hard coded path.
The quick solution (if you don't want to read the blog) is
C:\>for /d %i in ("\Program Files\Java\jdk*") do set JAVA_HOME=%i
C:\>set PATH=%PATH%;%JAVA_HOME%
You can then add these lines to a startup/login script.
I just had to do this to get this to work on windows 7 64.
Open up a command prompt (cmd.exe) and type:
set CLASSPATH=C:\Program Files\Java\jdk1.7.0_01\bin
Make sure you reopen all running command prompt Windows to get the environment variable updated as well.
Okay this can not be the case always but many of us have done this mistake in the past and few out of those are still not aware of it, which is, every time you append a path (any path) of any environment variable, you're likely to hit the space bar right after the "semicolon" (as you normally would, after the "period" while typing in an editor).
This will create a leading space in the path e.g " C:\Program Files\Java\jdk1.6.0\bin" and therefore "javac.exe" won't be found by the system.
Change the folder "jdk1.7.0_45" "jdk1_7_0_60" and update the path in Windows environment. Otherwise, the path ignores the dot at the front which stands for hidden file and so the folder is not displayed in PATH strings.
";C:\Program Files\Java\jdk1.6.0\bin" sometime you may forget to put semicolon on last existing path.
I faced the exact same problem that java would work but javac would not on a cmd prompt in Windows 8.
The problem occured because I forgot to remove '>'
at the end of the path name, i.e., it was like this:
C:\Program Files\Java\jdk*\bin>
where it was suppose to be like this:
C:\Program Files\Java\jdk*\bin
The path will only be set for the administrator account. Therefore it is important to launch command prompt as administrator, if you are not already.
Ensure you don't allow spaces (white space) in between paths in the Path variable. My problem was I had white space in and I believe Windows treated it as a NULL and didn't read my path in for Java.
I was having the same problem posted in this title. Java would work, but javac
would not in the Windows command prompt (cmd.exe
).
For me, it was simply that I had placed a space when adding C:\Program Files\Java\jdk1.8.0\bin
to the end of my %PATH%
environment variable.
Remove the space between the ;
and the next file path.
I appreciate this is an old question now but my solution wasn't an answer on here so posting it in case anyone else tries all the rest.
In my case, a previous install of the Java JRE (in ProgramData/Oracle/Java) had a path variable at the top of my list of path variables. The contents of that "Oracle" path had a java.exe but not a javac.exe. I added my full JDK path to the top of the list of path variables, ahead of the "Oracle" one, and it then picked up javac.exe as well as java.
for /d %i in ("\Program Files\Java\jdk*") do set JAVA_HOME=%i
set JAVA_HOME
this solution worked to me
When i tried to make the .java to .class the command Javac didnt work. I got it working by going to C:\Program Files (x86)\Java\jdk1.7.0_04\bin and when i was on that directory I typed Javac.exe C\Test\test.java and it made the class with that tactic. Try that out.
Give it as "C:\Program Files\Java\jdk1.6.0_16\bin". Remove the backslash it will work
참고 URL : https://stackoverflow.com/questions/1678520/javac-not-working-in-windows-command-prompt
'programing tip' 카테고리의 다른 글
신용 카드 유효 기간-포함 또는 독점? (0) | 2020.07.05 |
---|---|
일시적 데드 존이란 무엇입니까? (0) | 2020.07.05 |
Java로 화면 해상도를 얻으려면 어떻게해야합니까? (0) | 2020.07.04 |
스칼라에서 배열과리스트의 차이점 (0) | 2020.07.04 |
표에서 1을 선택한다는 것은 무슨 의미입니까? (0) | 2020.07.04 |