i try to run java program with ProcessBuilder
but it works only with .exe file and with .jar or .java
i use netbeans 6.9

why please?

import java.io.*;

public class Mani
public static void main(String args[])
        throws IOException, InterruptedException
Process p=Runtime.getRuntime().exec("javaw -jar D:\\NetBeansProjects\\GetIPAddress\\dist\\GetIPAddress.jar");
catch(IOException e1) {System.out.println(e1);}

I think the problem is:

1- i install java on my pc.
2- i install NetBeans 6.9

but i never i try javac on cmd
i always use netbeans for testing my code.

but today when i try to type "javac" on cmd it's not working, it doesn't recognize javac as an internal command.

how could resolve this problem on first?

thank you

no, no, not, please which OS (but I just something ..... about HP, As400 and Win platforms)

sure this way (via Runtime) you can run compiled Java aplication, but why

So could you explain to me why my code is not working?
i'm beginner in java.
with the same code if i try to execute .exe file like calc.exe it's working!

thank you

again, for which OS (Windows or ....), because command & path is so different for various Native OS

So my java is located here:


And i set path like this:

ClassPath is:

.;C:\Program Files\Java\jre6\lib\ext\QTJava.zip



PATH is:

C:\Program Files\Common Files\Microsoft Shared\Windows Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Common Files\Adobe\AGL;C:\Program Files\Common Files\Autodesk Shared;C:\Program Files\Windows Live\Shared;C:\Program Files\QuickTime\QTSystem\;set path=%path%;C:\Progammes\Java\jdk1.6.0_17\bin%JAVAHOME%\bin

I'm not sure about my setting for java.
i know one thing is that javac is located in C:\Programmes\Java\jdk1.6.0-17
and when i click it it's working but not from cmd windows

Thank you

Process p = Runtime.getRuntime().exec("cmd /c start java -jar D:\\NetBeansProjects\\GetIPAddress\\dist\\GetIPAddress.jar");

but why not run java from ShortCut (f.e. from DescTop)

In fact hwen i try to run the jar file only, it's not working
there is an error message :
Could not find the main class: getipaddress.GetIPAdress.Program will exit

Maybe my jar is not created correctly by netbeans
i don't know

if you are sets main class correctly, then works,

check the project properties

I'll use this one only if FatalError raised, why run java from Runtime.getRuntime().exec(...

This question has already been answered. Start a new discussion instead.