Buggy code:
public class HTML_Compiler { public static DecimalFormat df = new DecimalFormat ( "0000000000" ) ; public static void main ( String [ ] args ) { <START_BUG> String baseDir = ( new File ( args [ 0 ] ) . getAbsoluteFile ( ) . getParentFile ( ) . getPath ( ) ) + ( File . separator ) ; <END_BUG> String baseDirData = ( baseDir + "data" ) + ( File . separator ) ; System . out . println ( "Compiling<seq2seq4repair_space>HTML..." ) ; String a = new File ( args [ 0 ] ) . getName ( ) ; String filename = a . substring ( 0 , ( ( a . length ( ) ) - 4 ) ) ; String basename = args [ 0 ] . substring ( 0 , ( ( args [ 0 ] . length ( ) ) - 4 ) ) ; String pdfname = filename + ".pdf" ; String outfile = basename + ".html" ; try { String viewer ; String viewerHEAD = FileUtils . readFileToString ( new File ( ( baseDirData + "template-head-alasql.html" ) ) , utf8 ) ; String viewerTAIL = FileUtils . readFileToString ( new File ( ( baseDirData + "template-tail-alasql.html" ) ) , utf8 ) ; String add ; if ( CompleteRun_HTML . includeRes ) { add = "<//script>" ; } else { add = "<//script><seq2seq4repair_space><link<seq2seq4repair_space>rel=\"stylesheet\"<seq2seq4repair_space>href=\"viewer.css\"//>" + ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( "<link<seq2seq4repair_space>rel=\"stylesheet\"<seq2seq4repair_space>href=\"pivot.css\"//>" + "<link<seq2seq4repair_space>rel=\"stylesheet\"<seq2seq4repair_space>href=\"codemirror.css\"//>" ) + "<link<seq2seq4repair_space>rel=\"stylesheet\"<seq2seq4repair_space>href=\"jquery.dataTables.css\"//>" ) + "<link<seq2seq4repair_space>rel=\"stylesheet\"<seq2seq4repair_space>href=\"c3.css\"//>" ) + "" ) + "<script<seq2seq4repair_space>src=\"base64.js\"><//script>" ) + "<script<seq2seq4repair_space>src=\"d3.js\"><//script>" ) + "<script<seq2seq4repair_space>src=\"alasql.js\"><//script>" ) + "<script<seq2seq4repair_space>src=\"codemirror-compressed.js\"><//script>" ) + "<script<seq2seq4repair_space>src=\"c3.js\"><//script>" ) + "<script<seq2seq4repair_space>src=\"excanvas.compiled.js\"><//script>" ) + "<script<seq2seq4repair_space>src=\"diff_match_patch.js\"><//script>" ) + "<script<seq2seq4repair_space>src=\"jquery-1.11.2.min.js\"><//script>" ) + "<script<seq2seq4repair_space>src=\"pivot.js\"><//script>" ) + "<script<seq2seq4repair_space>src=\"jquery-ui-1.9.2.custom.min.js\"><//script>" ) + "<script<seq2seq4repair_space>src=\"jquery.dataTables.js\"><//script>" ) + "<script<seq2seq4repair_space>src=\"main.js\"><//script>" ) + "<script<seq2seq4repair_space>src=\"preMain.js\"><//script>" ) + "<script<seq2seq4repair_space>src=\"jstat.js\"><//script>" ) + "" ) + "<script<seq2seq4repair_space>src=\"compatibility.js\"><//script>" ) + "<script<seq2seq4repair_space>src=\"l10n.js\"><//script>" ) + "<script<seq2seq4repair_space>src=\"pdf.js\"><//script>" ) + "<script<seq2seq4repair_space>src=\"pdf.worker.js\"><//script>" ) + "<script<seq2seq4repair_space>src=\"viewer.js\"><//script>" ) + "<script<seq2seq4repair_space>src=\"lz-string.min.js\"><//script>" ) ; } String all = FileUtils . readFileToString ( new File ( ( baseDirData + "all" ) ) , utf8 ) ; String preload = FileUtils . readFileToString ( new File ( ( baseDir + "pdbf-preload" ) ) ) ; viewer = ( ( ( ( ( ( ( ( ( ( ( ( ( ( viewerHEAD + "pdf_base64<seq2seq4repair_space>=<seq2seq4repair_space>\"" ) + ( Tools . encodeFileToBase64Binary ( new File ( ( baseDir + pdfname ) ) ) ) ) + "\";\r\n" ) + "db_base64<seq2seq4repair_space>=<seq2seq4repair_space>\"\";\r\n" ) + "json_base64<seq2seq4repair_space>=<seq2seq4repair_space>\"" ) + ( Tools . encodeFileToBase64Binary ( new File ( ( baseDir + "pdbf-config.json" ) ) ) ) ) + "\";\r\n" ) + "dbjson_base64<seq2seq4repair_space>=<seq2seq4repair_space>\"" ) + ( Tools . escapeSpecialChars ( new File ( ( baseDir + "pdbf-db.json" ) ) ) ) ) + "\";\r\n" ) + preload ) + "\r\n" ) + ( CompleteRun_HTML . includeRes ? all + "\r\n" : "" ) ) + add ) + viewerTAIL ; String insert1 = "%<!DOCTYPE<seq2seq4repair_space>html><html<seq2seq4repair_space>dir=\"ltr\"<seq2seq4repair_space>mozdisallowselectionprint<seq2seq4repair_space>moznomarginboxes>" + "<head><meta<seq2seq4repair_space>charset=\"utf-8\"><!--\n" ; String insert2 = ( ( ( ( "1337<seq2seq4repair_space>0<seq2seq4repair_space>obj\n" + ( "stream\n" + "-->\n" ) ) + viewer ) + "<!--\n" ) + "endstream\n" ) + "endobj\n" ; StringBuilder sb = new StringBuilder ( FileUtils . readFileToString ( new File ( ( baseDir + pdfname ) ) , StandardCharsets . ISO_8859_1 ) ) ; int pdfmarker = sb . indexOf ( "%PDF-" ) ; int pdfmarkerend = sb . indexOf ( "\n" , pdfmarker ) ; sb . insert ( ( pdfmarkerend + 1 ) , insert2 ) ; sb . insert ( ( pdfmarkerend + 1 ) , insert1 ) ; int offset = ( insert1 . length ( ) ) + ( insert2 . length ( ) ) ; int b = ( sb . lastIndexOf ( "\nxref\n" ) ) + ( "\nxref\n" . length ( ) ) ; int e ; int x ; b = ( sb . indexOf ( "\n" , ( b + 1 ) ) ) + 1 ; e = sb . indexOf ( "<seq2seq4repair_space>" , b ) ; try { while ( true ) { b = ( sb . indexOf ( "\n" , ( b + 1 ) ) ) + 1 ; e = sb . indexOf ( "<seq2seq4repair_space>" , b ) ; String tmp = sb . substring ( b , e ) ; x = Integer . parseInt ( tmp ) ; sb . replace ( b , e , HTML_Compiler . df . format ( ( x + offset ) ) ) ; } } catch ( NumberFormatException ex ) { } b = ( sb . indexOf ( "startxref\n" ) ) + ( "startxref\n" . length ( ) ) ; e = sb . indexOf ( "\n" , b ) ; x = Integer . parseInt ( sb . substring ( b , e ) ) ; sb . replace ( b , e , ( "" + ( x + offset ) ) ) ; FileUtils . writeStringToFile ( new File ( outfile ) , sb . toString ( ) , StandardCharsets . ISO_8859_1 ) ; new File ( ( ( baseDir + basename ) + ".pdf" ) ) . delete ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } }

Fix:
String baseDir = new File ( CompleteRun_HTML . class . getProtectionDomain ( ) . getCodeSource ( ) . getLocation ( ) . getPath ( ) ) . getParent ( ) ;