diff --git a/src/org/ninjacave/jarsplice/JarSpliceLauncher.java b/src/org/ninjacave/jarsplice/JarSpliceLauncher.java index bcb2753..6b651e9 100644 --- a/src/org/ninjacave/jarsplice/JarSpliceLauncher.java +++ b/src/org/ninjacave/jarsplice/JarSpliceLauncher.java @@ -1,24 +1,9 @@ package org.ninjacave.jarsplice; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.PrintStream; -import java.net.URISyntaxException; -import java.net.URL; -import java.security.CodeSource; -import java.security.ProtectionDomain; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.Random; -import java.util.StringTokenizer; -import java.util.jar.Attributes; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.jar.Manifest; +import java.io.*; +import java.net.*; +import java.util.*; +import java.util.jar.*; public class JarSpliceLauncher { @@ -130,15 +115,15 @@ public String getNativeDirectory() { if ((nativeDir == null) || (System.getProperty("os.name").startsWith("Win"))) { nativeDir = System.getProperty("java.io.tmpdir"); } - - nativeDir = nativeDir + File.separator + "natives" + new Random().nextInt(); + if(!nativeDir.endsWith(File.separator)) + nativeDir+=File.separator; + nativeDir += "natives" + new Random().nextInt(); File dir = new File(nativeDir); if (!dir.exists()) { dir.mkdirs(); } - return nativeDir; } diff --git a/src/org/ninjacave/jarsplice/core/Splicer.java b/src/org/ninjacave/jarsplice/core/Splicer.java index 38ac225..f76d344 100644 --- a/src/org/ninjacave/jarsplice/core/Splicer.java +++ b/src/org/ninjacave/jarsplice/core/Splicer.java @@ -1,121 +1,174 @@ package org.ninjacave.jarsplice.core; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.jar.Attributes; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import org.ninjacave.jarsplice.JarSplice; +import java.io.*; +import java.util.*; +import java.util.jar.*; +import java.util.zip.*; +import org.ninjacave.jarsplice.*; public class Splicer { - ArrayList dirs = new ArrayList(); - int bufferSize; - byte[] buffer = new byte[4096]; - public void createFatJar(String[] jars, String[] natives, String output, String mainClass, String vmArgs) throws Exception { - this.dirs.clear(); + ArrayList dirs = new ArrayList(); + int bufferSize; + byte[] buffer = new byte[4096]; - Manifest manifest = getManifest(mainClass, vmArgs); - - FileOutputStream fos = new FileOutputStream(output); - JarOutputStream jos = new JarOutputStream(fos, manifest); - try + public void createFatJar(String[] jars, String[] natives, String output, String mainClass, String vmArgs) throws Exception { - addFilesFromJars(jars, jos); - addNativesToJar(natives, jos); - addJarSpliceLauncher(jos); + this.dirs.clear(); + services.clear(); + + Manifest manifest = getManifest(mainClass, vmArgs); + + FileOutputStream fos = new FileOutputStream(output); + JarOutputStream jos = new JarOutputStream(fos, manifest); + try + { + addFilesFromJars(jars, jos); + addNativesToJar(natives, jos); + addJarSpliceLauncher(jos); + processCachedServices(jos); + } + finally + { + jos.close(); + fos.close(); + } } - finally { - jos.close(); - fos.close(); + + protected Manifest getManifest(String mainClass, String vmArgs) + { + Manifest manifest = new Manifest(); + Attributes attribute = manifest.getMainAttributes(); + attribute.putValue("Manifest-Version", "1.0"); + attribute.putValue("Main-Class", "org.ninjacave.jarsplice.JarSpliceLauncher"); + attribute.putValue("Launcher-Main-Class", mainClass); + attribute.putValue("Launcher-VM-Args", vmArgs); + + return manifest; } - } - - protected Manifest getManifest(String mainClass, String vmArgs) { - Manifest manifest = new Manifest(); - Attributes attribute = manifest.getMainAttributes(); - attribute.putValue("Manifest-Version", "1.0"); - attribute.putValue("Main-Class", "org.ninjacave.jarsplice.JarSpliceLauncher"); - attribute.putValue("Launcher-Main-Class", mainClass); - attribute.putValue("Launcher-VM-Args", vmArgs); - - return manifest; - } - - protected void addFilesFromJars(String[] jars, JarOutputStream out) throws Exception - { - for (int i = 0; i < jars.length; i++) + + HashMap services = new HashMap<>(); + + private void cacheService(String filename, InputStream is) { - ZipFile jarFile = new ZipFile(jars[i]); + BufferedReader reader = new BufferedReader(new InputStreamReader(is)); + StringBuilder out = new StringBuilder(); + String line; + try + { + while ((line = reader.readLine()) != null) + { + out.append(line).append("\n"); + } + } + catch (IOException ex) + { + } - Enumeration entities = jarFile.entries(); + if (services.containsKey(filename)) + { + out.append(services.get(filename)); + services.replace(filename, out.toString()); + } + else + { + services.put(filename, out.toString()); + } + } - while (entities.hasMoreElements()) { - ZipEntry entry = (ZipEntry)entities.nextElement(); + private void processCachedServices(JarOutputStream out) throws IOException + { + for (String key : services.keySet()) + { + System.out.print(key); + out.putNextEntry(new ZipEntry(key)); + out.write(services.get(key).getBytes()); + out.closeEntry(); + } + } - if (entry.isDirectory()) { - if (!this.dirs.contains(entry.getName())) - { - this.dirs.add(entry.getName()); - } + protected void addFilesFromJars(String[] jars, JarOutputStream out) throws Exception + { + for (int i = 0; i < jars.length; i++) + { + ZipFile jarFile = new ZipFile(jars[i]); + + Enumeration entities = jarFile.entries(); + + while (entities.hasMoreElements()) + { + ZipEntry entry = (ZipEntry)entities.nextElement(); + boolean isService = entry.getName().toLowerCase().contains("meta-inf/services/"); + + if (entry.isDirectory()) + { + if (!this.dirs.contains(entry.getName())) + { + this.dirs.add(entry.getName()); + } + } + else if ((!entry.getName().toLowerCase().startsWith("meta-inf") || isService)) + { + if (isService) + { + InputStream in = jarFile.getInputStream(jarFile.getEntry(entry.getName())); + cacheService(entry.getName(), jarFile.getInputStream(jarFile.getEntry(entry.getName()))); + in.close(); + } + else if (!entry.getName().toLowerCase().contains("JarSpliceLauncher")) + { + InputStream in = jarFile.getInputStream(jarFile.getEntry(entry.getName())); + + out.putNextEntry(new ZipEntry(entry.getName())); + while ((this.bufferSize = in.read(this.buffer, 0, this.buffer.length)) != -1) + { + out.write(this.buffer, 0, this.bufferSize); + } + + in.close(); + out.closeEntry(); + } + } + } + jarFile.close(); } - else if (!entry.getName().toLowerCase().startsWith("meta-inf")) + } + + protected void addNativesToJar(String[] natives, JarOutputStream out) throws Exception + { + for (int i = 0; i < natives.length; i++) { - if (!entry.getName().toLowerCase().contains("JarSpliceLauncher")) - { - InputStream in = jarFile.getInputStream(jarFile.getEntry(entry.getName())); + InputStream in = new FileInputStream(natives[i]); - out.putNextEntry(new ZipEntry(entry.getName())); + out.putNextEntry(new ZipEntry(getFileName(natives[i]))); - while ((this.bufferSize = in.read(this.buffer, 0, this.buffer.length)) != -1) { - out.write(this.buffer, 0, this.bufferSize); + while ((this.bufferSize = in.read(this.buffer, 0, this.buffer.length)) != -1) + { + out.write(this.buffer, 0, this.bufferSize); } in.close(); out.closeEntry(); - } } - } - jarFile.close(); } - } - - protected void addNativesToJar(String[] natives, JarOutputStream out) throws Exception - { - for (int i = 0; i < natives.length; i++) { - InputStream in = new FileInputStream(natives[i]); - out.putNextEntry(new ZipEntry(getFileName(natives[i]))); - - while ((this.bufferSize = in.read(this.buffer, 0, this.buffer.length)) != -1) { - out.write(this.buffer, 0, this.bufferSize); - } + protected void addJarSpliceLauncher(JarOutputStream out) throws Exception + { + InputStream in = JarSplice.class.getResourceAsStream("JarSpliceLauncher.class"); - in.close(); - out.closeEntry(); + out.putNextEntry(new ZipEntry("org/ninjacave/jarsplice/JarSpliceLauncher.class")); + while ((this.bufferSize = in.read(this.buffer, 0, this.buffer.length)) != -1) + { + out.write(this.buffer, 0, this.bufferSize); + } + in.close(); + out.closeEntry(); } - } - protected void addJarSpliceLauncher(JarOutputStream out) throws Exception - { - InputStream in = JarSplice.class.getResourceAsStream("JarSpliceLauncher.class"); - - out.putNextEntry(new ZipEntry("org/ninjacave/jarsplice/JarSpliceLauncher.class")); - while ((this.bufferSize = in.read(this.buffer, 0, this.buffer.length)) != -1) { - out.write(this.buffer, 0, this.bufferSize); + protected String getFileName(String ref) + { + ref = ref.replace('\\', '/'); + return ref.substring(ref.lastIndexOf('/') + 1); } - in.close(); - out.closeEntry(); - } - - protected String getFileName(String ref) { - ref = ref.replace('\\', '/'); - return ref.substring(ref.lastIndexOf('/') + 1); - } } diff --git a/src/org/ninjacave/jarsplice/gui/CreatePanel.java b/src/org/ninjacave/jarsplice/gui/CreatePanel.java index 979f174..272ab47 100644 --- a/src/org/ninjacave/jarsplice/gui/CreatePanel.java +++ b/src/org/ninjacave/jarsplice/gui/CreatePanel.java @@ -1,17 +1,11 @@ package org.ninjacave.jarsplice.gui; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.io.PrintStream; -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.border.TitledBorder; +import java.awt.event.*; +import java.io.*; +import javax.swing.*; +import javax.swing.border.*; import javax.swing.filechooser.FileFilter; -import org.ninjacave.jarsplice.core.Splicer; +import org.ninjacave.jarsplice.core.*; public class CreatePanel extends JPanel implements ActionListener @@ -28,9 +22,9 @@ public CreatePanel(JarSpliceFrame jarSplice) { public void approveSelection() { File f = getSelectedFile(); if ((f.exists()) && (getDialogType() == 1)) { - int result = + int result = JOptionPane.showConfirmDialog( - this, "The file already exists. Do you want to overwrite it?", + this, "The file already exists. Do you want to overwrite it?", "Confirm Replace", 0); switch (result) { case 0: @@ -85,9 +79,9 @@ public String getOutputFile(File file) { public void actionPerformed(ActionEvent e) { if (e.getSource() == this.createButton) { - this.fileChooser.setCurrentDirectory(this.jarSplice.lastDirectory); + this.fileChooser.setCurrentDirectory(this.jarSplice.lastExportDirectory); int value = this.fileChooser.showSaveDialog(this); - this.jarSplice.lastDirectory = this.fileChooser.getCurrentDirectory(); + this.jarSplice.lastExportDirectory = this.fileChooser.getCurrentDirectory(); if (value == 0) { @@ -100,14 +94,14 @@ public void actionPerformed(ActionEvent e) { this.splicer.createFatJar(jars, natives, output, mainClass, vmArgs); - JOptionPane.showMessageDialog(this, - "Fat Jar Successfully Created.", + JOptionPane.showMessageDialog(this, + "Fat Jar Successfully Created.", "Success", -1); } catch (Exception ex) { ex.printStackTrace(); - JOptionPane.showMessageDialog(this, - "Jar creation failed due to the following exception:\n" + ex.getMessage(), + JOptionPane.showMessageDialog(this, + "Jar creation failed due to the following exception:\n" + ex.getMessage(), "Failed", 0); } diff --git a/src/org/ninjacave/jarsplice/gui/JarSpliceFrame.java b/src/org/ninjacave/jarsplice/gui/JarSpliceFrame.java index 663eed6..eaf4057 100644 --- a/src/org/ninjacave/jarsplice/gui/JarSpliceFrame.java +++ b/src/org/ninjacave/jarsplice/gui/JarSpliceFrame.java @@ -1,7 +1,7 @@ package org.ninjacave.jarsplice.gui; -import java.io.File; -import javax.swing.JFrame; +import java.io.*; +import javax.swing.*; public class JarSpliceFrame { @@ -13,13 +13,16 @@ public class JarSpliceFrame ShellScriptPanel shellScriptPanel = new ShellScriptPanel(this); MacAppPanel macAppPanel = new MacAppPanel(this); WinExePanel exePanel = new WinExePanel(this); - public File lastDirectory; + public File lastIconDirectory; + public File lastJarsDirectory; + public File lastNativesDirectory; + public File lastExportDirectory; public JarSpliceFrame() { //TITLE MODIFIED AS TO STATE THAT JARSPLICEPLUS IS AN EXTENSION TO JARSPLICE - + JFrame frame = new JFrame("JarSplicePlus - An Extension to JarSplice"); TabPane tabPane = new TabPane(this); diff --git a/src/org/ninjacave/jarsplice/gui/JarsPanel.java b/src/org/ninjacave/jarsplice/gui/JarsPanel.java index 25f84de..b91366b 100644 --- a/src/org/ninjacave/jarsplice/gui/JarsPanel.java +++ b/src/org/ninjacave/jarsplice/gui/JarsPanel.java @@ -1,16 +1,10 @@ package org.ninjacave.jarsplice.gui; -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import javax.swing.BorderFactory; -import javax.swing.DefaultListModel; -import javax.swing.JButton; -import javax.swing.JFileChooser; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.border.TitledBorder; +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import javax.swing.*; +import javax.swing.border.*; import javax.swing.filechooser.FileFilter; public class JarsPanel extends JPanel @@ -81,9 +75,9 @@ public String[] getSelectedFiles() { public void actionPerformed(ActionEvent e) { if (e.getSource() == this.addButton) { - this.fileChooser.setCurrentDirectory(this.jarSplice.lastDirectory); + this.fileChooser.setCurrentDirectory(this.jarSplice.lastJarsDirectory); int value = this.fileChooser.showDialog(this, "Add"); - this.jarSplice.lastDirectory = this.fileChooser.getCurrentDirectory(); + this.jarSplice.lastJarsDirectory = this.fileChooser.getCurrentDirectory(); if (value == 0) { this.selectedFiles = this.fileChooser.getSelectedFiles(); diff --git a/src/org/ninjacave/jarsplice/gui/MacAppPanel.java b/src/org/ninjacave/jarsplice/gui/MacAppPanel.java index d8a7eb2..54e3bd7 100644 --- a/src/org/ninjacave/jarsplice/gui/MacAppPanel.java +++ b/src/org/ninjacave/jarsplice/gui/MacAppPanel.java @@ -1,27 +1,13 @@ package org.ninjacave.jarsplice.gui; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.io.IOException; -import java.io.PrintStream; -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JFileChooser; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.UIManager; -import javax.swing.border.TitledBorder; +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import javax.swing.*; +import javax.swing.border.*; import javax.swing.filechooser.FileFilter; -import javax.swing.text.AttributeSet; -import javax.swing.text.BadLocationException; -import javax.swing.text.PlainDocument; -import org.ninjacave.jarsplice.core.MacAppSplicer; +import javax.swing.text.*; +import org.ninjacave.jarsplice.core.*; public class MacAppPanel extends JPanel implements ActionListener @@ -71,8 +57,8 @@ private JPanel createDescriptionPanel() JPanel descriptionPanel = new JPanel(); JLabel label = new JLabel(); label.setText( - String.format("
%s
", new Object[] { - Integer.valueOf(300), + String.format("
%s
", new Object[] { + Integer.valueOf(300), "This is an optional step and will create an OS X APP Bundle. If there are native files then only the Mac native files (*.jnilib and *.dylib) will be added to the APP Bundle." })); descriptionPanel.add(label); @@ -112,8 +98,8 @@ public JPanel createNamePanel() JPanel descriptionPanel = new JPanel(); JLabel label = new JLabel(); label.setText( - String.format("
%s
", new Object[] { - Integer.valueOf(300), + String.format("
%s
", new Object[] { + Integer.valueOf(300), "Set the name of the APP Bundle." })); descriptionPanel.add(label); @@ -154,8 +140,8 @@ public JPanel createIconPanel() JPanel descriptionPanel = new JPanel(); JLabel label = new JLabel(); label.setText( - String.format("
%s
", new Object[] { - Integer.valueOf(300), + String.format("
%s
", new Object[] { + Integer.valueOf(300), "Select the icon the app bundle will use. This should be in the Apple Icon Image format (*.icns)." })); descriptionPanel.add(label); @@ -182,9 +168,9 @@ private JFileChooser getFileChooser() { public void approveSelection() { File f = getSelectedFile(); if ((f.exists()) && (getDialogType() == 1)) { - int result = + int result = JOptionPane.showConfirmDialog( - this, "The file already exists. Do you want to overwrite it?", + this, "The file already exists. Do you want to overwrite it?", "Confirm Replace", 0); switch (result) { case 0: @@ -240,9 +226,9 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == this.macAppButton) { - this.fileChooser.setCurrentDirectory(this.jarSplice.lastDirectory); + this.fileChooser.setCurrentDirectory(this.jarSplice.lastExportDirectory); int value = this.fileChooser.showSaveDialog(this); - this.jarSplice.lastDirectory = this.fileChooser.getCurrentDirectory(); + this.jarSplice.lastExportDirectory = this.fileChooser.getCurrentDirectory(); if (value == 0) { String[] sources = this.jarSplice.getJarsList(); @@ -254,14 +240,14 @@ public void actionPerformed(ActionEvent e) { this.macAppSplicer.createAppBundle(sources, natives, output, mainClass, vmArgs, this.nameTextField.getText(), this.iconTextField.getText()); - JOptionPane.showMessageDialog(this, - "APP Bundle Successfully Created.", + JOptionPane.showMessageDialog(this, + "APP Bundle Successfully Created.", "Success", -1); } catch (Exception ex) { ex.printStackTrace(); - JOptionPane.showMessageDialog(this, - "APP Bundle creation failed due to the following exception:\n" + ex.getMessage(), + JOptionPane.showMessageDialog(this, + "APP Bundle creation failed due to the following exception:\n" + ex.getMessage(), "Failed", 0); } @@ -269,9 +255,9 @@ public void actionPerformed(ActionEvent e) } } else if (e.getSource() == this.iconButton) { - this.iconChooser.setCurrentDirectory(this.jarSplice.lastDirectory); + this.iconChooser.setCurrentDirectory(this.jarSplice.lastIconDirectory); int value = this.iconChooser.showDialog(this, "Add"); - this.jarSplice.lastDirectory = this.iconChooser.getCurrentDirectory(); + this.jarSplice.lastIconDirectory = this.iconChooser.getCurrentDirectory(); if (value == 0) { File iconFile = this.iconChooser.getSelectedFile(); diff --git a/src/org/ninjacave/jarsplice/gui/NativesPanel.java b/src/org/ninjacave/jarsplice/gui/NativesPanel.java index e6d3c84..c144d22 100644 --- a/src/org/ninjacave/jarsplice/gui/NativesPanel.java +++ b/src/org/ninjacave/jarsplice/gui/NativesPanel.java @@ -1,16 +1,10 @@ package org.ninjacave.jarsplice.gui; -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import javax.swing.BorderFactory; -import javax.swing.DefaultListModel; -import javax.swing.JButton; -import javax.swing.JFileChooser; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.border.TitledBorder; +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import javax.swing.*; +import javax.swing.border.*; import javax.swing.filechooser.FileFilter; public class NativesPanel extends JPanel @@ -37,9 +31,9 @@ public boolean accept(File file) { if (file.isDirectory()) return true; String filename = file.getName(); - return (filename.endsWith(".dll")) || - (filename.endsWith(".so")) || - (filename.endsWith(".jnilib")) || + return (filename.endsWith(".dll")) || + (filename.endsWith(".so")) || + (filename.endsWith(".jnilib")) || (filename.endsWith(".dylib")); } public String getDescription() { @@ -85,9 +79,9 @@ public String[] getSelectedFiles() { public void actionPerformed(ActionEvent e) { if (e.getSource() == this.addButton) { - this.fileChooser.setCurrentDirectory(this.jarSplice.lastDirectory); + this.fileChooser.setCurrentDirectory(this.jarSplice.lastNativesDirectory); int value = this.fileChooser.showDialog(this, "Add"); - this.jarSplice.lastDirectory = this.fileChooser.getCurrentDirectory(); + this.jarSplice.lastNativesDirectory = this.fileChooser.getCurrentDirectory(); if (value == 0) { this.selectedFiles = this.fileChooser.getSelectedFiles(); diff --git a/src/org/ninjacave/jarsplice/gui/ShellScriptPanel.java b/src/org/ninjacave/jarsplice/gui/ShellScriptPanel.java index 4910da4..d7edbe1 100644 --- a/src/org/ninjacave/jarsplice/gui/ShellScriptPanel.java +++ b/src/org/ninjacave/jarsplice/gui/ShellScriptPanel.java @@ -1,19 +1,12 @@ package org.ninjacave.jarsplice.gui; -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.io.PrintStream; -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JFileChooser; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.border.TitledBorder; +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import javax.swing.*; +import javax.swing.border.*; import javax.swing.filechooser.FileFilter; -import org.ninjacave.jarsplice.core.ShellScriptSplicer; +import org.ninjacave.jarsplice.core.*; public class ShellScriptPanel extends JPanel implements ActionListener @@ -30,9 +23,9 @@ public ShellScriptPanel(JarSpliceFrame jarSplice) { public void approveSelection() { File f = getSelectedFile(); if ((f.exists()) && (getDialogType() == 1)) { - int result = + int result = JOptionPane.showConfirmDialog( - this, "The file already exists. Do you want to overwrite it?", + this, "The file already exists. Do you want to overwrite it?", "Confirm Replace", 0); switch (result) { case 0: @@ -70,8 +63,8 @@ public String getDescription() { JPanel panel1 = new JPanel(); JLabel label = new JLabel(); label.setText( - String.format("
%s
", new Object[] { - Integer.valueOf(300), + String.format("
%s
", new Object[] { + Integer.valueOf(300), "This is an optional step and will create a Linux shellscript. This shellscript will contain all the jars and natives just like the executable jar. If there are native files then only the Linux native files (*.so) will be added to the shellscript." })); panel1.add(label); @@ -99,9 +92,9 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == this.shellScriptButton) { - this.fileChooser.setCurrentDirectory(this.jarSplice.lastDirectory); + this.fileChooser.setCurrentDirectory(this.jarSplice.lastExportDirectory); int value = this.fileChooser.showSaveDialog(this); - this.jarSplice.lastDirectory = this.fileChooser.getCurrentDirectory(); + this.jarSplice.lastExportDirectory = this.fileChooser.getCurrentDirectory(); if (value == 0) { String[] sources = this.jarSplice.getJarsList(); @@ -113,14 +106,14 @@ public void actionPerformed(ActionEvent e) { this.shellScriptSplicer.createFatJar(sources, natives, output, mainClass, vmArgs); - JOptionPane.showMessageDialog(this, - "ShellScript Successfully Created.", + JOptionPane.showMessageDialog(this, + "ShellScript Successfully Created.", "Success", -1); } catch (Exception ex) { ex.printStackTrace(); - JOptionPane.showMessageDialog(this, - "ShellScript creation failed due to the following exception:\n" + ex.getMessage(), + JOptionPane.showMessageDialog(this, + "ShellScript creation failed due to the following exception:\n" + ex.getMessage(), "Failed", 0); } diff --git a/src/org/ninjacave/jarsplice/gui/WinExePanel.java b/src/org/ninjacave/jarsplice/gui/WinExePanel.java index 12b938d..a3f6638 100644 --- a/src/org/ninjacave/jarsplice/gui/WinExePanel.java +++ b/src/org/ninjacave/jarsplice/gui/WinExePanel.java @@ -1,23 +1,12 @@ package org.ninjacave.jarsplice.gui; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.io.PrintStream; -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JFileChooser; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.UIManager; -import javax.swing.border.TitledBorder; +import java.awt.*; +import java.awt.event.*; +import java.io.*; +import javax.swing.*; +import javax.swing.border.*; import javax.swing.filechooser.FileFilter; -import org.ninjacave.jarsplice.core.WinExeSplicer; +import org.ninjacave.jarsplice.core.*; public class WinExePanel extends JPanel implements ActionListener @@ -50,8 +39,8 @@ private JPanel createAppPanel() { JPanel descriptionPanel = new JPanel(); JLabel label = new JLabel(); label.setText( - String.format("
%s
", new Object[] { - Integer.valueOf(300), + String.format("
%s
", new Object[] { + Integer.valueOf(300), "This is an optional step and will create a Windows EXE File. " })); descriptionPanel.add(label); @@ -103,8 +92,8 @@ public JPanel createIconPanel() JPanel descriptionPanel = new JPanel(); JLabel label = new JLabel(); label.setText( - String.format("
%s
", new Object[] { - Integer.valueOf(300), + String.format("
%s
", new Object[] { + Integer.valueOf(300), "Select the icon the exe will use. This should be in the*.png file format." })); descriptionPanel.add(label); @@ -130,9 +119,9 @@ private JFileChooser getFileChooser() { public void approveSelection() { File f = getSelectedFile(); if ((f.exists()) && (getDialogType() == 1)) { - int result = + int result = JOptionPane.showConfirmDialog( - this, "The file already exists. Do you want to overwrite it?", + this, "The file already exists. Do you want to overwrite it?", "Confirm Replace", 0); switch (result) { case 0: @@ -168,9 +157,9 @@ public void actionPerformed(ActionEvent e) { if (e.getSource() == this.winExeButton) { - this.fileChooser.setCurrentDirectory(this.jarSplice.lastDirectory); + this.fileChooser.setCurrentDirectory(this.jarSplice.lastExportDirectory); int value = this.fileChooser.showSaveDialog(this); - this.jarSplice.lastDirectory = this.fileChooser.getCurrentDirectory(); + this.jarSplice.lastExportDirectory = this.fileChooser.getCurrentDirectory(); if (value == 0) { String[] sources = this.jarSplice.getJarsList(); @@ -182,14 +171,14 @@ public void actionPerformed(ActionEvent e) { this.winExeSplicer.createFatJar(sources, natives, output, mainClass, vmArgs); - JOptionPane.showMessageDialog(this, - "EXE Successfully Created.", + JOptionPane.showMessageDialog(this, + "EXE Successfully Created.", "Success", -1); } catch (Exception ex) { ex.printStackTrace(); - JOptionPane.showMessageDialog(this, - "EXE creation failed due to the following exception:\n" + ex.getMessage(), + JOptionPane.showMessageDialog(this, + "EXE creation failed due to the following exception:\n" + ex.getMessage(), "Failed", 0); }