Rahman
Rahman

Reputation: 3785

Getting FileNotFoundException during execution of maven command

I am trying to run a maven command through my Java code. But its throwing following exception. However, I am able to run that same command through windows command prompt. Also,current user is having read permission for D:\MyProject folder .I verified it by checking the folder property.(Right click ->Properties->Security tab)

Can you please tell me why I am getting this exception ?

Code:

p = Runtime.getRuntime().exec("D://il-apache-maven-3.0.4.0//bin//mvn.bat clean install -DskipTests -e -f D://MyProject");

Exception :

java.io.FileNotFoundException: D:\MyProject (Access is denied)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at org.apache.maven.model.building.FileModelSource.getInputStream(FileModelSource.java:55)
    at org.apache.maven.model.building.DefaultModelBuilder.readModel(DefaultModelBuilder.java:456)

Upvotes: 2

Views: 201

Answers (1)

watchme
watchme

Reputation: 740

Your file cannot be found because this link is not interpreted that it points to a file but to a folder. Just change your link that it points to the right file or add the file-extension if "MyProject" is a file (Because if you don't add it, it is interpreted as a folder).

Upvotes: 2

Related Questions