D
Dave Rudolf
Hey all,
I am using the Runtime.exec() method do start other programs in Windows.
One of which is actually another java program, albeit started by a batch
file. When I run the batch file from the explorer or a command window,
it all works just fine. However, if I try to run it with
Runtime.execute(), it can't find java.exe (which the batch file needs)
in the execution path.
So, I had code that looked something like this:
Process process = Runtime.getRuntime().exec(
new String[]{
fullDirectory.getAbsolutePath() + "\\crayola_oblongata.bat" },
new String[ 0 ],
fullDirectory );
The batch file simply starts the java program, like so:
java.exe -jar crayola_oblongata_gui.jar crayonsh.exe
I get a run-time error which indicates to me that the system can't find
java.exe in the execution path
'java.exe' is not recognized as an internal or external command,
operable program or batch file.
I get the same error if I try to get cmd.exe to start the program for
me, like so:
Process process = Runtime.getRuntime().exec(
new String[]{
"cmd.exe", "/c", "crayola_oblongata.bat" },
new String[ 0 ],
fullDirectory );
Now, if I put java.exe directly into the arguments to exec(), like so
Process process = Runtime.getRuntime().exec(
new String[]{
"java.exe", "-jar", "crayola_oblongata_gui.jar", "crayonsh.exe" },
new String[ 0 ],
fullDirectory );
Then it finds java.exe, but I get the following very puzzling exception:
java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:161)
at javax.swing.ImageIcon.<init>(ImageIcon.java:147)
at
com.sun.java.swing.plaf.windows.WindowsFileChooserUI$ShortCutPanel.<init>(WindowsFileChooserUI.java:622)
at
com.sun.java.swing.plaf.windows.WindowsFileChooserUI.updateUseShellFolder(WindowsFileChooserUI.java:489)
at
com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installComponents(WindowsFileChooserUI.java:347)
at
javax.swing.plaf.basic.BasicFileChooserUI.installUI(BasicFileChooserUI.java:130)
at
com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installUI(WindowsFileChooserUI.java:176)
at javax.swing.JComponent.setUI(JComponent.java:449)
at javax.swing.JFileChooser.updateUI(JFileChooser.java:1701)
at javax.swing.JFileChooser.setup(JFileChooser.java:345)
at javax.swing.JFileChooser.<init>(JFileChooser.java:320)
at javax.swing.JFileChooser.<init>(JFileChooser.java:273)
at crayon.FrmMain.<init>(Unknown Source)
at crayon.FrmMain.<init>(Unknown Source)
at crayon.CrayolaOblongata.<init>(Unknown Source)
at crayon.CrayolaOblongata.main(Unknown Source)
Exception in thread "main"
So, any guesses as to how I might fix this problem?
Thanks.
Dave
I am using the Runtime.exec() method do start other programs in Windows.
One of which is actually another java program, albeit started by a batch
file. When I run the batch file from the explorer or a command window,
it all works just fine. However, if I try to run it with
Runtime.execute(), it can't find java.exe (which the batch file needs)
in the execution path.
So, I had code that looked something like this:
Process process = Runtime.getRuntime().exec(
new String[]{
fullDirectory.getAbsolutePath() + "\\crayola_oblongata.bat" },
new String[ 0 ],
fullDirectory );
The batch file simply starts the java program, like so:
java.exe -jar crayola_oblongata_gui.jar crayonsh.exe
I get a run-time error which indicates to me that the system can't find
java.exe in the execution path
'java.exe' is not recognized as an internal or external command,
operable program or batch file.
I get the same error if I try to get cmd.exe to start the program for
me, like so:
Process process = Runtime.getRuntime().exec(
new String[]{
"cmd.exe", "/c", "crayola_oblongata.bat" },
new String[ 0 ],
fullDirectory );
Now, if I put java.exe directly into the arguments to exec(), like so
Process process = Runtime.getRuntime().exec(
new String[]{
"java.exe", "-jar", "crayola_oblongata_gui.jar", "crayonsh.exe" },
new String[ 0 ],
fullDirectory );
Then it finds java.exe, but I get the following very puzzling exception:
java.lang.NullPointerException
at javax.swing.ImageIcon.<init>(ImageIcon.java:161)
at javax.swing.ImageIcon.<init>(ImageIcon.java:147)
at
com.sun.java.swing.plaf.windows.WindowsFileChooserUI$ShortCutPanel.<init>(WindowsFileChooserUI.java:622)
at
com.sun.java.swing.plaf.windows.WindowsFileChooserUI.updateUseShellFolder(WindowsFileChooserUI.java:489)
at
com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installComponents(WindowsFileChooserUI.java:347)
at
javax.swing.plaf.basic.BasicFileChooserUI.installUI(BasicFileChooserUI.java:130)
at
com.sun.java.swing.plaf.windows.WindowsFileChooserUI.installUI(WindowsFileChooserUI.java:176)
at javax.swing.JComponent.setUI(JComponent.java:449)
at javax.swing.JFileChooser.updateUI(JFileChooser.java:1701)
at javax.swing.JFileChooser.setup(JFileChooser.java:345)
at javax.swing.JFileChooser.<init>(JFileChooser.java:320)
at javax.swing.JFileChooser.<init>(JFileChooser.java:273)
at crayon.FrmMain.<init>(Unknown Source)
at crayon.FrmMain.<init>(Unknown Source)
at crayon.CrayolaOblongata.<init>(Unknown Source)
at crayon.CrayolaOblongata.main(Unknown Source)
Exception in thread "main"
So, any guesses as to how I might fix this problem?
Thanks.
Dave