1 /* 2 * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * 26 * 27 * Used by BootClassPath.sh. 28 * 29 * Given a "work directory" this class creates a sub-directory with a 30 * name that uses locale specific characters. It the creates a jar 31 * manifest file in the work directory with a Boot-Class-Path that 32 * encodes the created sub-directory. Finally it creates a file 33 * "boot.dir" in the work directory with the name of the sub-directory. 34 */ 35 import java.io.File; 36 import java.io.FileOutputStream; 37 import java.nio.charset.Charset; 38 39 public class Setup { 40 41 public static void main(String[] args) throws Exception { 42 if (args.length < 2) { 43 System.err.println("Usage: java Setup <work-dir> <premain-class>"); 44 return; 45 } 46 String workDir = args[0]; 47 String premainClass = args[1]; 48 49 String manifestFile = workDir + fileSeparator + "MANIFEST.MF"; 50 String bootClassPath = "boot" + suffix(); 51 52 String bootDir = workDir + fileSeparator + bootClassPath; 53 54 55 /* 56 * Create sub-directory 57 */ 58 File f = new File(bootDir); 59 f.mkdir(); 60 61 /* 62 * Create manifest file with Boot-Class-Path encoding the 63 * sub-directory name. 64 */ 65 try (FileOutputStream out = new FileOutputStream(manifestFile)) { 66 out.write("Manifest-Version: 1.0\n".getBytes("UTF-8")); 67 68 byte[] premainBytes = 69 ("Premain-Class: " + premainClass + "\n").getBytes("UTF-8"); 70 out.write(premainBytes); 71 72 out.write( "Boot-Class-Path: ".getBytes("UTF-8") ); 73 | 1 /* 2 * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 * 26 * 27 * Used by BootClassPath.sh. 28 * 29 * Given a "work directory" this class creates a sub-directory with a 30 * name that uses locale specific characters. It then creates a jar 31 * manifest file in the work directory with a Boot-Class-Path that 32 * encodes the created sub-directory. Finally it creates a file 33 * "boot.dir" in the work directory with the name of the sub-directory. 34 */ 35 import java.io.File; 36 import java.io.FileOutputStream; 37 import java.nio.charset.Charset; 38 39 public class Setup { 40 41 public static void main(String[] args) throws Exception { 42 if (args.length < 2) { 43 System.err.println("Usage: java Setup <work-dir> <premain-class>"); 44 return; 45 } 46 String workDir = args[0]; 47 String premainClass = args[1]; 48 49 String manifestFile = workDir + fileSeparator + "MANIFEST.MF"; 50 String bootClassPath = "boot" + suffix(); 51 52 String bootDir = workDir + fileSeparator + bootClassPath; 53 54 /* 55 * Environment variable settings ("null" if unset) 56 */ 57 System.out.println("Env vars:"); 58 System.out.println(" LANG=" + System.getenv("LANG")); 59 System.out.println(" LC_ALL=" + System.getenv("LC_ALL")); 60 System.out.println(" LC_CTYPE=" + System.getenv("LC_CTYPE")); 61 62 /* 63 * Create sub-directory 64 */ 65 File f = new File(bootDir); 66 f.mkdir(); 67 68 /* 69 * Create manifest file with Boot-Class-Path encoding the 70 * sub-directory name. 71 */ 72 try (FileOutputStream out = new FileOutputStream(manifestFile)) { 73 out.write("Manifest-Version: 1.0\n".getBytes("UTF-8")); 74 75 byte[] premainBytes = 76 ("Premain-Class: " + premainClass + "\n").getBytes("UTF-8"); 77 out.write(premainBytes); 78 79 out.write( "Boot-Class-Path: ".getBytes("UTF-8") ); 80 |