• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

runtime.exec()

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In JNI to run class file in any OS we use runtime.exec() method ...told.

How to use it and when to use?
 
author
Posts: 23965
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by amit bhadre:
In JNI to run class file in any OS we use runtime.exec() method ...told.

How to use it and when to use?



Not really sure what you are asking... so apologies if this doesn't apply.

JNI and Runtime.exec() are two different things. JNI is used to interface to a native library -- a DLL for Windows and a shared library for Unix. And Runtime.exec() is a method that allows you to call a program in the OS.

The only relation that I can think of is... maybe Runtime uses JNI under the covers. For you, you should use JNI, if you have a library that you need to interface to, and Runtime.exec(), if you have a program that you want to call.

Henry
 
amit bhadre
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello sir I am glad to receive such responses from... really sir.

exicited...

As u told now that Runtime.exec() is a method that allows you to call a program in the OS.

So if want run a class file then I can use this method sir? If so how please tel me with e.g...

Or can I call like this

Object o=null;
o=runtime.exec(a);

Here 'a' may be any class name... is it gives the output of that class file sir, here 'a'.

Thanking u in advance ....


 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Runtime.exec is for executing system commands (which you would normally enter on the command line).

If you want to "run" class files, why don't you instantiate the class, and call its methods as appropriate?

Or are you talking about running a Java application, like "java -classpath ... MyJavaClass"? Then Runtime.exec is for you, although it has caveats to be aware of.
[ February 20, 2006: Message edited by: Ulf Dittmer ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic