Source:
<code>private File createJar( @Nonnull List<String> classPath, @Nonnull String startClassName ) throws IOException { File file = File.createTempFile( "surefirebooter", ".jar", getTempDirectory() ); if ( !isDebug() ) { file.deleteOnExit(); } Path parent = file.getParentFile().toPath(); FileOutputStream fos = new FileOutputStream( file ); JarOutputStream jos = new JarOutputStream( fos ); try { jos.setLevel( JarOutputStream.STORED ); JarEntry je = new JarEntry( "META-INF/MANIFEST.MF" ); jos.putNextEntry( je ); Manifest man = new Manifest(); StringBuilder cp = new StringBuilder(); for ( Iterator<String> it = classPath.iterator(); it.hasNext(); ) { File file1 = new File( it.next() ); String uri; try { <START> uri = URI.create( parent.relativize( file1.toPath() ).toString() ).toASCIIString(); <END> } catch ( IllegalArgumentException e ) { uri = file1.toURI().toASCIIString(); getConsoleLogger().warning( "Boot Manifest-JAR contains absolute paths in classpath" ); } cp.append( uri ); if ( file1.isDirectory() && !uri.endsWith( "/" ) ) { cp.append( '/' ); } if ( it.hasNext() ) { cp.append( ' ' ); } } man.getMainAttributes().putValue( "Manifest-Version", "1.0" ); man.getMainAttributes().putValue( "Class-Path", cp.toString().trim() ); man.getMainAttributes().putValue( "Main-Class", startClassName ); man.write( jos ); jos.closeEntry(); jos.flush(); return file; } finally { jos.close(); } }</code><technical_language>is a reason I suggested three-arg URI constructor create. want _construct_ a URI a raw path, _parse_ a URI. jshell> URI.create("../../a b/c.jar") | java.lang.IllegalArgumentException thrown: Illegal character in path index 7: ../../a b/c.jar | URI.create (URI.java:883) | (#6:1) jshell> new URI(null, "../../a b/c.jar", null) $7 ==> ../../a%20b/c.jar</technical_language>

Target:
private File createJar( @Nonnull List<String> classPath, @Nonnull String startClassName ) throws IOException { File file = File.createTempFile( "surefirebooter", ".jar", getTempDirectory() ); if ( !isDebug() ) { file.deleteOnExit(); } Path parent = file.getParentFile().toPath(); FileOutputStream fos = new FileOutputStream( file ); JarOutputStream jos = new JarOutputStream( fos ); try { jos.setLevel( JarOutputStream.STORED ); JarEntry je = new JarEntry( "META-INF/MANIFEST.MF" ); jos.putNextEntry( je ); Manifest man = new Manifest(); StringBuilder cp = new StringBuilder(); for ( Iterator<String> it = classPath.iterator(); it.hasNext(); ) { File file1 = new File( it.next() ); String uri; try { uri = new URI( null, parent.relativize( file1.toPath() ).toString(), null ).toASCIIString(); } catch ( IllegalArgumentException e ) { uri = file1.toURI().toASCIIString(); } catch ( URISyntaxException e ) { throw new IOException( "Could not relativize path " + file1 + " against " + parent, e ); } cp.append( uri ); if ( file1.isDirectory() && !uri.endsWith( "/" ) ) { cp.append( '/' ); } if ( it.hasNext() ) { cp.append( ' ' ); } } man.getMainAttributes().putValue( "Manifest-Version", "1.0" ); man.getMainAttributes().putValue( "Class-Path", cp.toString().trim() ); man.getMainAttributes().putValue( "Main-Class", startClassName ); man.write( jos ); jos.closeEntry(); jos.flush(); return file; } finally { jos.close(); } }