Skip to main content

File.createTempFile() throws exception on Win7

2 replies [Last post]
jitinsingla
Offline
Joined: 2010-09-10
Points: 0

When i call File.createTempFile() on a Win7 system it throws the following exception. This happens when i run my application as a windows service. If i run the application just as a simple java application then it works fine.

java.io.IOException: The system cannot find the path specified
at java.io.WinNTFileSystem.createFileExclusively(Nati ve Method)
at java.io.File.checkAndCreate(Unknown Source)
at java.io.File.createTempFile(Unknown Source)
at java.io.File.createTempFile(Unknown Source)
at com.ultravisual.app.client.CmdLineContextAdapter.g etImageData(CmdLineContextAdapter.java:260)
at com.ultravisual.pcm.routing.RoutingService.runIter ation(RoutingService.java:357)
at com.ultravisual.pcm.routing.RoutingServiceWindowsR unner.run(RoutingServiceWindowsRunner.java:168)
at java.lang.Thread.run(Unknown Source)

Both System environment (TEMP, TMP) variables are set to C:\Windows\Temp.
Both User environment (TEMP, TMP) variables are set to %USERPROFILE%\AppData\Local\Temp.

Also i confirmed that both these directories exist on the workstation.

I would really appreciate if somebody could help me out with this problem

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
theface
Offline
Joined: 2005-09-18
Points: 0

Hey.maybe you should upgrade your jdk/jse to latest version.

The latest java 6 dosen't contains this API:java.io.File.checkAndCreate.

walterln
Offline
Joined: 2007-04-17
Points: 0

It does as a private method called by createTempFile.

@OP, what is the value of system property java.io.tmpdir? Make sure it's a folder your service was write permission on.