skylot/jadx · error · JadxArgsValidateException

directory exists as file

Error message

${desc} directory exists as file ${dir}

What it means

An argument-validation error from JadxArgsValidator.checkDir(), used for the output source/resource/output directories. If a directory path exists on disk but resolves to a regular file (not a directory), jadx cannot create or write into it and throws JadxArgsValidateException naming the descriptor (e.g. 'output source') and the conflicting path. This is checked during initialization.

Solutions

  1. Remove or rename the conflicting regular file at the reported path.
  2. Point the output directory argument at a path that does not collide with an existing file.
  3. Clear the output location between runs, or use a fresh output directory.
  4. Pre-check with Files.isDirectory(Path) (and !Files.isRegularFile) before setting the arg.

Example fix

// before
args.setOutDirSrc(new File("out/src")); // a file named 'src' already exists under out/

// after
File srcDir = new File("out/src");
if (srcDir.exists() && !srcDir.isDirectory()) {
    throw new IllegalStateException("'src' exists as a file, refusing to overwrite: " + srcDir);
}
args.setOutDirSrc(srcDir);
Defensive patterns

Strategy: validation

Validate before calling

private static File checkOutDir(File dir, String desc) {
    if (dir != null && dir.exists() && !dir.isDirectory()) {
        throw new IllegalStateException(desc + " path is a file, not a directory: " + dir);
    }
    return dir;
}
checkOutDir(args.getOutDirSrc(), "source out");
checkOutDir(args.getOutDirRes(), "resource out");

Try / catch

try {
    decompiler.load();
} catch (JadxArgsValidateException e) {
    if (e.getMessage().contains("exists as file")) {
        // remove/rename the conflicting file, then retry
        new File(conflictingPath).delete();
        decompiler.load();
    } else throw e;
}

Prevention

When it happens

Trigger: Setting args.setOutDirSrc()/setOutDirRes()/setOutDir() to a path that is already occupied by a file (e.g., a file named 'src' exists where jadx wants a 'src/' directory).

Common situations: A previous run left a regular file where a directory is now expected; a path collision where an output file and an output directory share a name; users pointing the source dir at an existing source file by mistake.

Related errors


AI-assisted analysis of skylot/jadx@e738a26571 (2026-08-14). Data as JSON: /api/errors/4acdfca0ddd69241. Report an issue: GitHub.

Appendix: source

Thrown at jadx-core/src/main/java/jadx/api/JadxArgsValidator.java:90

			if (pos != -1) {
				outDirName = name.substring(0, pos);
			} else {
				outDirName = name + '-' + JadxArgs.DEFAULT_OUT_DIR;
			}
		}
		LOG.info("output directory: {}", outDirName);
		return new File(outDirName);
	}

	private static void checkFile(File file) {
		if (!file.exists()) {
			throw new JadxArgsValidateException("File not found " + file.getAbsolutePath());
		}
	}

	private static void checkDir(File dir, String desc) {
		if (dir != null && dir.exists() && !dir.isDirectory()) {
			throw new JadxArgsValidateException(desc + " directory exists as file " + dir);
		}
	}

	private JadxArgsValidator() {
	}
}

View on GitHub (pinned to e738a26571)