Search code examples
javadirectorypermissionsjavac

Java Compilation error for selective directories


javac filename.java NOT WORKING in "C:\Users\Idiot\OneDrive\Documents\NiT\5th Semester\OOP with Java\LAB\DAY_1" but working just fine in "D:"

I have already tried setting the path to "C:\Program Files\Java\jdk-12.0.2\bin"

C:\Users\Idiot\OneDrive\Documents\NiT\5th Semester\OOP with Java\LAB\DAY_1>dir
 Volume in drive C has no label.
 Volume Serial Number is 0ED7-AEA4

 Directory of C:\Users\Idiot\OneDrive\Documents\NiT\5th Semester\OOP with Java\LAB\DAY_1

02-09-2019  16:13    <DIR>          .
02-09-2019  16:13    <DIR>          ..
02-09-2019  16:28               151 Demo.java
02-09-2019  16:28               187 Factorial.java
02-09-2019  16:28               643 Fibo.java
02-09-2019  16:28               339 Pattern.java
02-09-2019  16:27               235 Temp.java
               5 File(s)          1,555 bytes
               2 Dir(s)  99,578,114,048 bytes free

C:\Users\Idiot\OneDrive\Documents\NiT\5th Semester\OOP with Java\LAB\DAY_1>javac Demo.java
Demo.java:2: error: error while writing Demo: C:\Users\Idiot\OneDrive\Documents\NiT\5th Semester\OOP with Java\LAB\DAY_1\Demo.class
class Demo
^
1 error
---------------------
D:\>dir
 Volume in drive D is New Volume
 Volume Serial Number is 92C6-DE71

 Directory of D:\

02-09-2019  16:28               151 Demo.java
02-09-2019  20:18    <DIR>          DOWNLOADS
30-07-2019  22:24    <DIR>          program files
01-09-2019  00:51    <DIR>          SharedFolder
30-07-2019  21:35    <DIR>          Temp
               2 File(s)          1,014 bytes
               5 Dir(s)  175,516,921,856 bytes free

D:\>javac Demo.java

D:\>java Demo
Result : 17

Solution

  • Is it possible that your user does not have permission to write into C:\Users\Idiot\OneDrive\Documents\NiT\5th Semester\OOP with Java\LAB\DAY_1\ ? Can you manually create a file in this directory? It might also be that spaces in the path cause a problem. Those should generally be avoided.