Process p=Runtime.getRuntime().exec(execute);
BufferedReader br=new BufferedReader(new
InputStreamReader(p.getInputStream()));
String line;
while((line=br.readLine())!=null)
{
System.out.println(line);
}
still I get nothing, I am not getting any clue as to what is happening.
A particular piece of code which was once working is not working now.
Where does the problem lie, any help would be highly appreciated...
Rohit Gupta
>I am having problem over and over again using it.
>This time I cant even figure out whats the problem.
>I am using getRuntime().exec() to run another java program( say p1) on
>a button click in JFrames, it was working fine. I made some changes in
>p1 after that and then compiled the code, now when I am again trying to
>press the button to execute the file nothing is happening. Its not
>executing.
Do you know that p1 works as it should after the modifications? Have
you tried running it by it self?
>I wrote following lines of code to see what I am getting as
>output after executing:
>
>Process p=Runtime.getRuntime().exec(execute);
> BufferedReader br=new BufferedReader(new
>InputStreamReader(p.getInputStream()));
> String line;
> while((line=br.readLine())!=null)
> {
> System.out.println(line);
> }
Try reading the error stream as well.
And print out the command string to verify it.
--
Johan Utne Poppe
Exception in thread "main" java.lang.NoClassDefFoundError: while
resolving class: hinuri1
at java.lang.VMClassLoader.resolveClass(java.lang.Class)
(/usr/lib64/libgcj.so.5.0.0)
at java.lang.Class.initializeClass() (/usr/lib64/libgcj.so.5.0.0)
at java.lang.Class.forName(java.lang.String, boolean,
java.lang.ClassLoader) (/usr/lib64/libgcj.so.5.0.0)
at gnu.gcj.runtime.FirstThread.run() (/usr/lib64/libgcj.so.5.0.0)
at _Jv_ThreadRun(java.lang.Thread) (/usr/lib64/libgcj.so.5.0.0)
at _Jv_RunMain(java.lang.Class, byte const, int, byte const,
boolean) (/usr/lib64/libgcj.so.5.0.0)
at __gcj_personality_v0
(/misc/fs11/bt2003/rohitg/InputPanel/java.home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre)
at __libc_start_main (/lib64/tls/libc-2.3.3.so)
at _Jv_RegisterClasses
(/misc/fs11/bt2003/rohitg/InputPanel/java.home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre)
Caused by: java.lang.ClassNotFoundException: java.lang.StringBuilder
not found in [file:/usr/share/java/libgcj-3.4.2.jar, file:./, core:/]
at java.net.URLClassLoader.findClass(java.lang.String)
(/usr/lib64/libgcj.so.5.0.0)
at gnu.gcj.runtime.VMClassLoader.findClass(java.lang.String)
(/usr/lib64/libgcj.so.5.0.0)
at java.lang.ClassLoader.loadClass(java.lang.String, boolean)
(/usr/lib64/libgcj.so.5.0.0)
at _Jv_FindClass(_Jv_Utf8Const, java.lang.ClassLoader)
(/usr/lib64/libgcj.so.5.0.0)
at java.lang.Class.forName(java.lang.String, boolean,
java.lang.ClassLoader) (/usr/lib64/libgcj.so.5.0.0)
at _Jv_BytecodeVerifier.verify_instructions_0()
(/usr/lib64/libgcj.so.5.0.0)
at _Jv_VerifyMethod(_Jv_InterpMethod) (/usr/lib64/libgcj.so.5.0.0)
at _Jv_PrepareClass(java.lang.Class) (/usr/lib64/libgcj.so.5.0.0)
at _Jv_WaitForState(java.lang.Class, int)
(/usr/lib64/libgcj.so.5.0.0)
at java.lang.VMClassLoader.linkClass0(java.lang.Class)
(/usr/lib64/libgcj.so.5.0.0)
at java.lang.VMClassLoader.resolveClass(java.lang.Class)
(/usr/lib64/libgcj.so.5.0.0)
...8 more
hinuri1 is p1.
I have both the files( java and class file) placed in the correct
location, so why is it showing NoClassDefFoundError...
I printed out the execute string and it is fine, as it should be...
Rohit Gupta
Well, for starters it is probably in the areas that you changed which
I'm gathering is not the above snippet.
Try to write a SSCCE that exhibits the issue and post it here.
HTH,
Ray
--
XML is the programmer's duct tape.
Rohit Gupta
ps: I had copied the modified project in windows( on a different comp.)
and ran it, it wasnt there previously.
>yeah p1 works as it should have been after modifications, I tried
>running it by itself.
>I get the following output on reading the errorstream:
>
>Exception in thread "main" java.lang.NoClassDefFoundError: while
>resolving class: hinuri1
...
>Caused by: java.lang.ClassNotFoundException: java.lang.StringBuilder
>not found in [file:/usr/share/java/libgcj-3.4.2.jar, file:./, core:/]
> at java.net.URLClassLoader.findClass(java.lang.String)
...
This looks like a classpath problem to me. It seems that you get
different settings for the JVM when you run it with exec from another
JVM instance than when you run from the command line. I am not sure
whether it's the class 'hinuri1' or 'java.lang.StringBuilder' it can't
find, though. Note that StringBuilder is a new class in java2 SE 5.0,
it could be that for some reason you end up with an older jvm when you
exec. (You could try to exec "java -version")
>hinuri1 is p1.
By the way, it's a very common convention in Java to capitalize class
names, i.e. the class should be called Hinuri1 and not hinuri1.
--
Johan Utne Poppe
>I am using getRuntime().exec() to run another java program( say p1) on
>a button click in JFrames, it was working fine.
You realise you are not allowed to use exec in unsigned Applets.
Does any message show up on the console?
--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm
Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
> java.lang.NoClassDefFoundError:
see
http://mindprod.com/jgloss/runerrormessages.html#NOCLASSDEFFOUNDERROR
>It was working fine before...means I just made trivial changes in the
>p1 file, that of changing the file name which it produced as output and
>then its not working. Before that it was fine.
See http://mindprod.com/jgloss/dependencies.html
Make sure every class you need is in the jar.
>In the subject line I have written its Frames.
"Frames" has many meanings.
I had previously used JApplets but because of the security problem I
had to resort to JFrames.