I am running into trouble with a java program, which attempts to write files to the /tmp directory on Ubuntu 18.10. It runs into errors as it can not write the temporary file it expects. It fails for error 2: No such file or directory. The privileges on /tmp are default.

I have read this is not a problem with Windows or Mac OS for the reason that it would not be restricted in this way.

How do I solve this? Should I configure my system differently (preferred) or alter the code?


The file in question is actually created, permissions are -rwxrwxr-x 1 lucas lucas 51263 Apr 26 11:12 monalisa13902330713449850714bin*

However, the the program cannot find it:

monalisa.tools.tinv.TInvariantCalculator$InvokeProcessException: java.io.IOException: Cannot run program "/tmp/monalisa13902330713449850714bin" (in directory "/tmp"): error=2, No such file or directory

The /tmp directory is determined correctly by File(System.getProperty("java.io.tmpdir"));

The file is created here:

    toolFile = FileUtils.extractResource("tinv_unix", "monalisa", "bin");
    public static File extractResource(URL resource, String prefix,
            String suffix) throws IOException {
        LOGGER.debug("Extracting resource '" + resource.toString() + "'");
        File file = File.createTempFile(prefix, suffix);
        file.setExecutable(true, false);

Running exec /tmp/[file name] returns the same error.

  • Please add the part of the code where the file is set and the write operation happens. Generally you should use java.io.tmpdir for temporary files which can be /tmp on some systems.
    – Freddy
    Apr 25, 2019 at 14:50
  • Just to be sure: the asterisk at the end of what looks like a partial output of ls is because of this, right? In the actual filename there is none, right? Please confirm. Apr 26, 2019 at 10:20
  • Yes, it is only because of ll
    – ljf
    Apr 26, 2019 at 10:23


You must log in to answer this question.

Browse other questions tagged .