I have a filename named \"first.java\" saved on my desktop in notepad++. When I run the cmd command \"javac first.java\" it gives me this error.
javac: file
As KhAn SaAb has stated, you need to set your path.
But in order for your JDK to take advantage of tools such as Maven in the future, I would assign a JAVA_HOME
path to point to your JDK folder and then just add the %JAVA_HOME%\bin
directory to your PATH
.
JAVA_HOME = "C:\Program Files\Java\jdk1.8.0"
PATH = %PATH%\%JAVA_HOME%\bin
In Windows:
blah;blah;blah;
C:\Program Files\Java\jdk1.8.0\bin;blah,blah;blah
to:
blah;blah;blah;
%JAVA_HOME%\bin;blah,blah;blah
First set your path to C:/Program Files/Java/jdk1.8.0/bin in the environment variables. Say, your file is saved in the C: drive Now open the command prompt and move to the directory using c: javac Filename.java java Filename
Make sure you save the file name as .java.
If it is saved as a text file name then file not found error results as it cannot the text file.
If this is the problem then go to the place where the javac is present and then type
It will work for sure.
SET path of JRE as well
jre is nothing but responsible for execute the program
PATH Variable value:
C:\Program Files\Java\jdk1.8.0\bin;C:\Program Files\Java\jre\bin;.;
Seems like you have your path right. But what is your working directory? on command prompt run:
javac -version
this should show your java version. if it doesnt, you have not set java in path correctly.
navigate to C:
cd \
Then:
javac -sourcepath users\AccName\Desktop -d users\AccName\Desktop first.java
-sourcepath is the complete path to your .java file, -d is the path/directory you want your .class files to be, then finally the file you want compiled (first.java).
just open file then click on save as then name it as first.java then in that box there is another dropdown in that dropdown (save as type) select type as all and save it now you can compile it