title: How to generate an ISO with JIIC
body: <p>I'm trying to generate an ISO file, for burning it on CDs, in JAVA. After a search I have found JIIC (Java Iso Image Creator) which is available <a href="http://sourceforge.net/projects/jiic/" rel="nofollow">on Source Forge</a> or <a href="http://search.maven.org/#search%7Cga%7C1%7Cjiic" rel="nofollow">as a Maven dependency</a>.</p>
  
  <p>I have made a simple java class to only generate an ISO but my program does not terminate correctly i.e. it never stops.</p>
  
  <pre><code>public class ISOtest {
  
      private static boolean enableJoliet    = true;
      private static boolean enableRockRidge = true;
      private static boolean enableElTorito  = true;
  
      private static void handleOption(String option) {
        if (option.equals("disable-joliet")) {
            enableJoliet = false;
        } else
        if (option.equals("disable-rockridge")) {
            enableRockRidge = false;
        } else
        if (option.equals("disable-eltorito")) {
            enableElTorito = false;
        }
      }
  
      public static void main(String[] args) throws Exception {
  
          System.out.println("Start");
  
          // Output file
          File outfile = new File(args.length&gt;0 ? args[0] : "ISOTest3.iso");
  
          // Directory hierarchy, starting from the root
          ISO9660RootDirectory.MOVED_DIRECTORIES_STORE_NAME = "rr_moved";
          ISO9660RootDirectory root = new ISO9660RootDirectory();
  
          if (args.length &gt; 1) {
  
              System.out.println("    If");
  
              // Record specified files and directories
  
              for (int i=1; i&lt;args.length; i++) {
                  if (args[i].startsWith("--")) {
                      handleOption(args[i].substring(2, args[i].length()));
                  } else {
                      // Add file or directory contents recursively
                      File file = new File(args[i]);
                      if (file.exists()) {
                          if (file.isDirectory()) {
                              root.addContentsRecursively(file);
                          } else {
                              root.addFile(file);
                          }
                      }
                  }
              }
          } else {
              // Record test cases
              // Additional test cases
              // (file without extension, tar.gz, deeply nested directory;
              // sort order tests, renaming tests: filename + extension,
              // directory with many files: sector end test)
              root.addRecursively(new File("test"));
  
              ISO9660File file1 = new ISO9660File("test/tux.gif", 1);
              root.addFile(file1);
              ISO9660File file10 = new ISO9660File("test/tux.gif", 10);
              root.addFile(file10);
              ISO9660File file12 = new ISO9660File("test/tux.gif", 12);
              root.addFile(file12);
          }
  
  
          // ISO9660 support
          System.out.println("ISO9660 support");
          ISO9660Config iso9660Config = new ISO9660Config();
          iso9660Config.allowASCII(false);
          iso9660Config.setInterchangeLevel(1);
          iso9660Config.restrictDirDepthTo8(true);
          iso9660Config.setPublisher("Jens Hatlak");
          iso9660Config.setVolumeID("ISO Test");
          iso9660Config.setDataPreparer("Jens Hatlak");
  
          iso9660Config.setCopyrightFile(new File("Copyright.txt"));
          iso9660Config.forceDotDelimiter(true);
  
          RockRidgeConfig rrConfig = null;
          if (enableRockRidge) {
              // Rock Ridge support
              rrConfig = new RockRidgeConfig();
              rrConfig.setMkisofsCompatibility(false);
              rrConfig.hideMovedDirectoriesStore(true);
              rrConfig.forcePortableFilenameCharacterSet(true);
          }
  
          JolietConfig jolietConfig = null;
          if (enableJoliet) {
              // Joliet support
              jolietConfig = new JolietConfig();
              jolietConfig.setPublisher("Test 1");
              jolietConfig.setVolumeID("Joliet Test");
              jolietConfig.setDataPreparer("Jens Hatlak");
              jolietConfig.setCopyrightFile(new File("Copyright.txt"));
              jolietConfig.forceDotDelimiter(true);
          }
  
          ElToritoConfig elToritoConfig = null;
          if(enableElTorito) {
  
              elToritoConfig = new ElToritoConfig(new File("tomsrtbt-2.0.103.ElTorito.288.img"),
                                                           ElToritoConfig.BOOT_MEDIA_TYPE_2_88MEG_DISKETTE,
                                                           ElToritoConfig.PLATFORM_ID_X86, "isoTest", 4,
                                                           ElToritoConfig.LOAD_SEGMENT_7C0);
          }
  
          // Create ISO
          System.out.println("Create ISO");
          ISOImageFileHandler streamHandler = new ISOImageFileHandler(outfile);
          System.out.println("streamHandler");
          CreateISO iso = new CreateISO(streamHandler, root);
          System.out.println("iso");
          iso.process(iso9660Config, rrConfig, jolietConfig, elToritoConfig);
          System.out.println("process");
          System.out.println("Done. File is: " + outfile);
      }
  }
  </code></pre>
  
  <p>In my console, I have the following result from the several <code>System.out.println</code></p>
  
  <blockquote>
    <p><code>Start
    ISO9660 support
    Create ISO
    streamHandler
    iso</code></p>
  </blockquote>
  
  <p>The program can't achieve the method "process" from the "CreateISO" class. 
  My ISO is create but it can't be open as an archive and its size is 0 octet.</p>
  
  <p>What is my fault ?</p>
  
  <h2>Stacktrace</h2>
  
  <p>The stacktrace in the debug panel.</p>
  
  <pre class="lang-none prettyprint-override"><code>ISO9660Handler(StandardHandler).&lt;init&gt;StreamHandler,ISO9660Directory,StandardCon‌​fig) line:35
  ISO9660Handler.&lt;init&gt;(StreamHandler, ISO9660RootDirectory, ISO9660Config, RockRidgeConfig) line: 48
  CreateISO.process(ISO9660Config, RockRidgeConfig, JolietConfig, ElToritoConfig) line: 57
  ISOtest.main(String[]) line: 150
  </code></pre>