Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Strange problem with using getRuntime.exec() in Frames

0 views
Skip to first unread message

Rohit Gupta

unread,
Jun 25, 2005, 7:34:18 AM6/25/05
to
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. 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);
}

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

Johan Poppe

unread,
Jun 25, 2005, 8:07:54 AM6/25/05
to
Rohit Gupta wote:

>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

Rohit Gupta

unread,
Jun 25, 2005, 8:13:06 AM6/25/05
to
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
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

Raymond DeCampo

unread,
Jun 25, 2005, 9:18:39 AM6/25/05
to

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

unread,
Jun 25, 2005, 9:26:02 AM6/25/05
to
just to add( maybe that would help).....I had made the whole thing in
netbeans, and now when I am running the same thing on windows its
working perfectly fine. I am more perplexed now....where does the
problem lie and how to get rid of it......why isnt it working on linux.
It was working on both the platforms before the modification.
plz help, I need to get it working on both the platforms....

Rohit Gupta

ps: I had copied the modified project in windows( on a different comp.)
and ran it, it wasnt there previously.

Johan Poppe

unread,
Jun 25, 2005, 11:56:57 AM6/25/05
to
Rohit Gupta wrote:

>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

Rohit Gupta

unread,
Jun 25, 2005, 3:40:20 PM6/25/05
to
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. The java version which I
am using is jdk1.5 which comes with netbeans4.0. When I am using it on
a diff machine with identical settings its working. The problem caused
hardly seem to be due to the changes made because that would not affect
the execution of the program and else wise also its getting executed on
the terminal. Is it that the some previous classes present are not
getting modified after making the changes so its causing some sort of
conflict or so, I dont know what is happening...feeling helpless now.

Roedy Green

unread,
Jun 26, 2005, 3:38:54 AM6/26/05
to
On 25 Jun 2005 04:34:18 -0700, "Rohit Gupta" <rg....@gmail.com> wrote
or quoted :

>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

Rohit Gupta

unread,
Jun 26, 2005, 5:07:20 AM6/26/05
to
In the subject line I have written its Frames.

Roedy Green

unread,
Jun 26, 2005, 6:11:05 AM6/26/05
to
On 25 Jun 2005 05:13:06 -0700, "Rohit Gupta" <rg....@gmail.com> wrote
or quoted :

> java.lang.NoClassDefFoundError:

see
http://mindprod.com/jgloss/runerrormessages.html#NOCLASSDEFFOUNDERROR

Roedy Green

unread,
Jun 26, 2005, 6:11:54 AM6/26/05
to
On 25 Jun 2005 12:40:20 -0700, "Rohit Gupta" <rg....@gmail.com> wrote
or quoted :

>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.

Roedy Green

unread,
Jun 26, 2005, 6:12:28 AM6/26/05
to
On 26 Jun 2005 02:07:20 -0700, "Rohit Gupta" <rg....@gmail.com> wrote
or quoted :

>In the subject line I have written its Frames.

"Frames" has many meanings.

Rohit Gupta

unread,
Jun 26, 2005, 6:37:21 AM6/26/05
to
Ya, every class is present in the jar. I checked it.

I had previously used JApplets but because of the security problem I
had to resort to JFrames.

0 new messages