"Javac is not recognized as an internal or external command, operable program or batch file in Windows 7" Solved!
Well i have started java training at the start of January,well still continuing Core Java and come to know about this normal error when i try to Compile java file in Command prompt.
basically this kind of problem arise when you are compiling java file without giving java compiler source with it hence it throws a technical error called Javac is not recognized as an internal or external command.
Hence to overcome this error there are common two ways
1. Temporary
2. Permanent
1. Temporary method
in this method what you need to do is to give your compiler address as a path in command prompt before compiling your .java file hence to this i have a simple way just look at it,
Before this i want to discuss with you that i have installed java version 7 in c drive with default location C:\Program Files\Java\jdk1.7.0_20\bin
in your bin folder both compiler and interpreter are present so by giving its path will direct the command prompt that your compiler is present in that directory and it will use it to compile your java file
so in order to compile a simple .java file in command prompt with temporary method is just like that
C:\Users\windows>cd\
C:\>D:
D:\>cd javaprog
D:\javaprog>set path="C:\Program Files\Java\jdk1.7.0_20\bin"
D:\javaprog>javac abc.java
D:\javaprog>java abc
Hi I Am Deepak
well its a simple method to run program and you all know it but the actual problem comes when you write every day same set path command hence instead of this permanent fix is used.
2. Permanent method
To create a pre-set path in the environment of windows you can overcome this headache of writing set path in the command prompt every-time.
to do this first you need to open properties of my computer and then open System protection tab at the sidebar and after then click advanced tab.
Now click environment variables.its important as when we set path name and variables they will make a fix in the system to consider the path of compilor whenever you come to call it in the program.
Now when you open environment variables click new in "User variables for windows"
now what we going to do is to make to variable names and with same variable value.
at first create Variable Name- CLASSPATH and Variable name- C:\Program Files\Java\jdk1.6.0_20\bin
and after then create another variable name- PATH and Variable name- C:\Program Files\Java\jdk1.6.0_20\bin
and click ok both.
Now do again with same steps in below System Variable Section Same method
Variable name- CLASSPATH
Variable value- C:\Program Files\Java\jdk1.6.0_20\bin
Variable name- PATH
Variable value- C:\Program Files\Java\jdk1.6.0_20\bin
Click ok both times and that's it, now start your command prompt again close if running before otherwise effect will not be seen.
restart it again and instead of set path command simply compile your java file directly i.e.
C:\Users\windows>cd\
C:\>D:
D:\>cd javaprog
// SKIP IT D:\javaprog>set path="C:\Program Files\Java\jdk1.7.0_20\bin"
D:\javaprog>javac abc.java
D:\javaprog>java abc
Hi I Am Deepak
and thats it, permanent fix for your compiling problem.
0 comments:
Post a Comment