package spikes; import java.io.File; import java.io.FileInputStream; import java.net.URL; import java.net.URLClassLoader; import java.util.Properties; import java.util.logging.Level; import javax.swing.JOptionPane; import javax.swing.JWindow; import tmcsim.common.SimulationException; /** * Spike to reveal working directory anomaly with Jar files. * @author jdalbey */ public class ShowUserDir { public ShowUserDir() { // This shows the path to where the Jar is located String currpath = getClass().getProtectionDomain().getCodeSource().getLocation().getPath(); JOptionPane.showMessageDialog(new JWindow(), currpath, "Show Jar Path", JOptionPane.INFORMATION_MESSAGE); // This shows the current working directory, which is different // if you double-click launch in Nautilus from command line launch. JOptionPane.showMessageDialog(new JWindow(), "\nUser.Dir=" + System.getProperty("user.dir"), "Show User Dir", JOptionPane.INFORMATION_MESSAGE); } public static void main(String[] args) { new ShowUserDir(); } }