diff --git a/java/src/main/java/ai/onnxruntime/OnnxRuntime.java b/java/src/main/java/ai/onnxruntime/OnnxRuntime.java index 0830ed5b7db39..742805bebc0fd 100644 --- a/java/src/main/java/ai/onnxruntime/OnnxRuntime.java +++ b/java/src/main/java/ai/onnxruntime/OnnxRuntime.java @@ -155,7 +155,7 @@ static synchronized void init() throws IOException { if (loaded) { return; } - tempDirectory = isAndroid() ? null : Files.createTempDirectory("onnxruntime-java"); + tempDirectory = Files.createTempDirectory("onnxruntime-java"); try { libraryDirPathProperty = System.getProperty(ONNXRUNTIME_NATIVE_PATH); // Extract and prepare the shared provider library but don't try to load it, @@ -181,9 +181,7 @@ static synchronized void init() throws IOException { version = initialiseVersion(); loaded = true; } finally { - if (tempDirectory != null) { - cleanUp(tempDirectory.toFile()); - } + cleanUp(tempDirectory.toFile()); } }