Java can't read image input file. - java

here is the screenshothere is the screenshot error
please help me solve this error for e to deploy our system this week.

It cannot find the file specified. The error is right there, FileNotFoundException.
Things to look into to remedy this.
1) Is the file actually there
2) Does java have access to that folder or are their access restrictions on it
3) Did you type the path correctly, looks like you are using unescaped windows style \ slashes which java doesn't like (thought it should have thrown the error earlier
Try looking at some of those errors. For more information on the FileNotFoundException https://docs.oracle.com/javase/7/docs/api/java/io/FileNotFoundException.html?is-external=true

Related

Java creates temp folder with shortened path and throws 'Not found' exception when trying to access files placed in it

so I did run into one very weird issue. The idea is simple: create temp dir, place some files in it and then try to access them. Now the problem is that calling File.createTempDir() or Files.createTempDirectory(prefix) creates new file inside AppData/Local/temp with shortened path, so the full path to folder looks something like C:/Users/FirstNam~1/AppData/Local/Temp/myFolder/myFile.txt instead of C:/Users/FirstName LastName/AppData/Local/Temp/myFolder.myFile.txt.
The difference is that generated path inside java contains FirstNam~1 instead of FistName SecondName. Java then throws exception File Not Found.
When I try to copy and paste shortened path into file explorer I get an error saying that file does not exist, but if I do change shortened path to full one then file opens and it works as intended.
Is there any way to fix it? Ether by forcing java to use full path names or enabling something in windows? I did Enable NTFS long paths policy, but it did not help.
This is happening when using java 8/11 and windows 10 running on VM, project is using AGP and gradle. Temp file is created inside groovy file that extends Plugin<Project>
Just when I lose hope and create a ticket, couple hours after that I find the answer. So, java has method Path.toRealPath() which solves this ~1 issue. After using this method paths no longer contain shortening and are correctly resolved.
EDIT: looks like java is doing everything correct and paths are actually valid, problem did come from library that I'm using and it's a bug with it.

Java System Level deployment Malformed deployment.config file

I am trying to install Java jre 1.8u31 from the command line. I am using system level install configuration by using the deployment.config file and deployment.properties.
I have tried the following:
deployment.system.config=file\:C\:/WINDOWS/Sun/Java/Deployment/deployment.properties
deployment.system.config.mandatory=true
I have also tried the following
deployment.system.config=file:///C:/Windows/Sun/Java/Deployment/deployment.properties
deployment.system.config.mandatory=true
I have swapped the entries around in hopes of getting a better error describing what I am doing wrong. I have also made the first line blank in the deployment.config file. I have googled and tried all examples I could find online. In all the cases, I am being presented a dialog box with an error that states the deployment.config file's line 1 is malformed.
Any suggestions would be greatly appreciated.
Russ
I have tried all of these formats:
The path you have given should be in below format
deployment.system.config=file:/C:/Windows/Sun/Java/Deployment/deployment.proper‌​ties
I got the install to work correctly. What I did was put the deployment.config file in the C:\Windows\Sun\Java\Deployment directory. The property in the file was setup as so:
deployment.system.config=file\:C\:\\Sup\\Java\\UPGRADE\\Deployment\\deployment.properties
The exceptionlist file was in the same directory as the deployment.properties file.

IllegalArgumentException when running app. (Android)

When running my project, I get this error.
Error:java.lang.IllegalArgumentException: Invalid resource path: C:\Android\Source Code and Samples\turbo-editor-master\turbo-editor-master\app\src\main\res
Any idea what is causing this?
I am using source code from the Turbo Editor app and have done no changes to the app prior to running it.
Try two things:
- Clean your project. This helps most of the times
- Go to the directory mentioned in the Exception. Make sure it actually exists.
I found the error. While looking at the error, follow the path that it is referring to. If there is no path like that, or a file missing, then create it and move the file to that path. Should fix the problem.
Illegal argument exception is throwed when a function gets wrong (it cannot reasonably deal with it) argument. This can be caused by, for example, missing function that was somewhere overrided. In your case - maybe this is issue with path? I'm not sure but if the path exists you can try changing it so it does not have "spaces" and capital letters. Please dump complete log with error.

NoSuchFileException/FileNotFounException. Is there universal way to know path(or paths) where this file was looking for?

often I have NoSuchFileException and FileNotFounException problem. And every time I should to google, read documenatation where concrete method searches this file or folder. I don't understand why don't I see error message in format -I tried to search your file in following paths .... but it doesn't exist there.
Maybe does exist way to get message in following format?

Java File can't open certain files

I'm trying to open files from within Java with something like this:
java.awt.Desktop.getDesktop().open(new File("c:\\coolfile.txt");
Of course it all works fine and dandy in most cases.
HOWEVER!
When I have a file with the unicode character u3000, I cannot open it! Even if the file exists.
For example:
java.awt.Desktop.getDesktop().open(new File("c:\\coolfile\u3000withweirdname.txt");
I get an Exception, EVEN WHEN THE FILE EXISTS
[java] java.io.IOException: Failed to open file:/E:/_prog/test%E3%80%80.txt. Error message: The system cannot find the path specified.
Please help me i tried pretty much everything. This is driving me insane :/
Edit:
To give some more info:
I can easily create file with this name from Java.
It seems it has something to do with whitespace
I don't know if it applies to other characters; I didn't find any yet. But of course if there's 1 there could easily be 100.
I'm pretty sure I can't read from the file or write to it from Java, but I haven't tested that since it isn't my main concern.
java.awt.Desktop.getDesktop().open(new File("c:\\coolfile\u3000withweirdname.txt");
That doesn't compile. Clearly it isn't your real code.
[java] java.io.IOException: Failed to open
file:/E:/_prog/test%E3%80%80.txt
And there is proof. Clearly you passed a URL to new FileInputStream(). It doesn't take a URL string, it takes a file name.
Ok i think i actually found a kind of solution to my question and i post it here to help any people that may have similar problems.
This fix only works for Windows (XP and up i think) BUT i don't even know if this problem exist in other OS. And even if it does a similar fix should be possible.
I am using the following code to succesfully open a file with the character:
Process p = new ProcessBuilder("cmd", "/c start \"\" \"E:\_prog\test\u3000.txt\"").start();
Which opens the file 'E:_prog\testu3000.txt'
As far as i know \u3000 is ideographic space character. To test your code I created a file with name CompanyAlt+3000Address.
Note: when you press Alt+3000, windows will create an ideographic space character. Then I copied the file name, to my java program and it worked for me.
Desktop.getDesktop().open(new File("C:\\Users\\Chandru\\Desktop\\Company╕Address.txt"));

Categories

Resources