Please help with executing a java program from another java program

Hi, I have tried to execute a very simple java program which is printed out "Hello world" from another java gui program when the user click on the "START" button. However, I don't receive any print out on the terminal when they click it. These two programs are being developed in Unix environment. Here is the code that I am trying to use.
Runtime r = Runtime.getRuntime();
r.exec("java HelloWorld");
p.s. HelloWorld is java class of the HelloWorld.java

I think you have to luanch your MS Prompt first before executing the command.

Similar Messages

  • How to compile and run a .java file from another java program

    hello,
    can any one tell me how to compile and run a *.java* file from another java program which is not in same directory?

    Well a smarter way of implementing this is by using a solution provided by Java Itself.
    If you are using J2SE 6.0+ there is an in built solution provided along with JDK itself and inorder to go ahead with solution the below are set of API which you;d be using it for compiling Java Programs (Files)
    http://java.sun.com/javase/6/docs/api/javax/tools/package-summary.html
    How do i do that ??
    Check out the below articles which would help you of how to do that
    http://www.ibm.com/developerworks/java/library/j-jcomp/index.html
    http://www.javabeat.net/javabeat/java6/articles/java_6_0_compiler_api_1.php
    http://books.google.com/books?id=WVbpv8SQpkEC&pg=PA155&lpg=PA155&dq=%22javax+tools%22+compiling+java+file&source=web&ots=XOt0siYe-f&sig=HH27ovuwvJgklIf8omTykUmy-eM
    Now once we are done with compilation.In order to run a Specific class all you ought to do is create an object and its specific methods of a specified class included in the CLASSPATH which you can manage it easily by usage little bit reflections.
    Hope that might help :)
    REGARDS,
    RaHuL

  • Trying to compile a .java file from another .java file

    Hello,
    I'm trying to compile a .java file from another .java file using Runtime.exec...
    String c[]=new String[3];
    c[0]="cmd.exe"; c[1]="/c" ; c[2]="javac Hello.java";
    Process p=Runtime.exec(c);
    If anyone can help me in atleast getting the command prompt when Runtime.exec("cmd.exe") is executed...that would be great...I tried out notepad.exe, calc, explorer instead of cmd.exe...all the commands display their respective windows..except cmd.exe...the command prompt doesnt appear...
    Please help me ASAP....
    Thanks for your help in advance...
    Regards.
    AKhila.

    try this. ur code will be compliled and will get .class file. but console won't appear. is it a must for u?
    public class Exec{
         public static void main(String a[]) throws Exception{
              String c[]=new String[3];
              c[0]="cmd.exe"; c[1]="/c" ; c[2]="javac Hello.java";
              Process p=Runtime.getRuntime().exec(c);
              // or Runtime.getRuntime().exec("javac Hello.java");

  • How to call a Java class from another java class ??

    Hi ..... can somebody plz tell me
    How to call a Java Class from another Java Class assuming both in the same Package??
    I want to call the entire Java Class  (not any specific method only........I want all the functionalities of that class)
    Please provide me some slotuions!!
    Waiting for some fast replies!!
    Regards
    Smita Mohanty

    Hi Smita,
    you just need to create an object of that class,thats it. Then you will be able to execute each and every method.
    e.g.
    you have developed A.java and B.java, both are in same package.
    in implementaion of B.java
    class B
                A obj = new A();
                 //to access A's methods
                 A.method();
                // to access A's variable
                //either
               A.variable= value.
               //or
               A.setvariable() or A.getvariable()

  • How to call a Dialog Program from another Dialog Program

    Dear All,
    How can I call a dialog program with return value from another dialog program?
    Regards,
    Alok.

    Hi Alok,
    1. Insted of creating 2 different Dialog program. It's good to create as many screens as you want in same module pool program. Any way you can use the different TCODE for each screen.
    2. Another and The best way is to create a function group and then inside function group use the function 2 module... In the function group define a global variable which will be present for both the function group if they are getting executed in sequence. and inside the Function Module call the screens using command " call screen <screenno>".
    3. You can use set / get parameter to pass values of a field between two dynpro program.

  • How to pass values to a module pool program from another Report Program

    Hi ..
    Please let me know how I can pass values to a MODULE POOL selection screen field from another Report Program.
    Thanks
    RK

    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9e0435c111d1829f0000e829fbfe/frameset.htm

  • Please, help with Live Audio/Video example from jmf solutions

    Hello,
    I�m desperate looking for a solution for a particular problem.
    I�m trying to feed JMF with an AudioInputStream generated via Java Sound, so that I can send it via RTP. The problem is that I don�t know how to properly create a DataSource from an InputStream. I know the example Live Audio/Video Data from the jmf solutions focuses on something similar.
    The problem is that I don�t know exactly how it works, os, the question is, how can I modify that example in order to use it and try to create a proper DataSource from the AudioInputStream, and then try to send it via RTP?
    I think that I manage to create a DataSource and pass it to the class AVTransmit2 from the jmf examples, and from that DataSource create a processor, which creates successfully, and then find a corresponding format and try to send it, but when i try to send it or play it I get garbage sound, so I�m not really sure whether I create the DataSource correctly or not, as I�ve made some changes on the Live Audio/Video Data from the jmf solutions to construct a livestream from the audioinputstream. Actually, I don�t understand where in the code does it construct the DataSource from the livestream, from an inputStream, because there�s not constructor like this DataSource(InputStream) neither nothing similar.
    Please help me as I�m getting very stuck with this, I would really appreciate your help,
    thanks for your time, bye.

    import javax.media.*;
    import javax.media.format.*;
    import javax.media.protocol.*;
    import java.io.IOException;
    import javax.sound.sampled.AudioInputStream;
    public class LiveAudioStream implements PushBufferStream, Runnable {
        protected ContentDescriptor cd = new ContentDescriptor(ContentDescriptor.RAW);
        protected int maxDataLength;
        protected int vez = 0;
        protected AudioInputStream data;
        public AudioInputStream audioStream;
        protected byte[] audioBuffer;
        protected javax.media.format.AudioFormat audioFormat;
        protected boolean started;
        protected Thread thread;
        protected float frameRate = 20f;
        protected BufferTransferHandler transferHandler;
        protected Control [] controls = new Control[0];
        public LiveAudioStream(byte[] audioBuf) {
             audioBuffer = audioBuf;
                      audioFormat = new AudioFormat(AudioFormat.ULAW,
                          8000.0,
                          8,
                          1,
                          Format.NOT_SPECIFIED,
                          AudioFormat.SIGNED,
                          8,
                          Format.NOT_SPECIFIED,
                          Format.byteArray);
                      maxDataLength = 40764;
                      thread = new Thread(this);
         * SourceStream
        public ContentDescriptor getContentDescriptor() {
         return cd;
        public long getContentLength() {
         return LENGTH_UNKNOWN;
        public boolean endOfStream() {
         return false;
         * PushBufferStream
        int seqNo = 0;
        double freq = 2.0;
        public Format getFormat() {
             return audioFormat;
        public void read(Buffer buffer) throws IOException {
         synchronized (this) {
             Object outdata = buffer.getData();
             if (outdata == null || !(outdata.getClass() == Format.byteArray) ||
              ((byte[])outdata).length < maxDataLength) {
              outdata = new byte[maxDataLength];
              buffer.setData(audioBuffer);          
              buffer.setFormat( audioFormat );
              buffer.setTimeStamp( 1000000000 / 8 );
             buffer.setSequenceNumber( seqNo );
             buffer.setLength(maxDataLength);
             buffer.setFlags(0);
             buffer.setHeader( null );
             seqNo++;
        public void setTransferHandler(BufferTransferHandler transferHandler) {
         synchronized (this) {
             this.transferHandler = transferHandler;
             notifyAll();
        void start(boolean started) {
         synchronized ( this ) {
             this.started = started;
             if (started && !thread.isAlive()) {
              thread = new Thread(this);
              thread.start();
             notifyAll();
         * Runnable
        public void run() {
         while (started) {
             synchronized (this) {
              while (transferHandler == null && started) {
                  try {
                   wait(1000);
                  } catch (InterruptedException ie) {
              } // while
             if (started && transferHandler != null) {
              transferHandler.transferData(this);
              try {
                  Thread.currentThread().sleep( 10 );
              } catch (InterruptedException ise) {
         } // while (started)
        } // run
        // Controls
        public Object [] getControls() {
         return controls;
        public Object getControl(String controlType) {
           try {
              Class  cls = Class.forName(controlType);
              Object cs[] = getControls();
              for (int i = 0; i < cs.length; i++) {
                 if (cls.isInstance(cs))
    return cs[i];
    return null;
    } catch (Exception e) {   // no such controlType or such control
    return null;
    and the other one, the DataSource,
    import javax.media.Time;
    import javax.media.protocol.*;
    import java.io.IOException;
    import java.io.InputStream;
    import javax.sound.sampled.AudioInputStream;
    public class CustomDataSource extends PushBufferDataSource {
        protected Object [] controls = new Object[0];
        protected boolean started = false;
        protected String contentType = "raw";
        protected boolean connected = false;
        protected Time duration = DURATION_UNKNOWN;
        protected LiveAudioStream [] streams = null;
        protected LiveAudioStream stream = null;
        public CustomDataSource(LiveAudioStream ls) {
             streams = new LiveAudioStream[1];
             stream = streams[0]= ls;
        public String getContentType() {
         if (!connected){
                System.err.println("Error: DataSource not connected");
                return null;
         return contentType;
        public byte[] getData() {
             return stream.audioBuffer;
        public void connect() throws IOException {
          if (connected)
                return;
          connected = true;
        public void disconnect() {
         try {
                if (started)
                    stop();
            } catch (IOException e) {}
         connected = false;
        public void start() throws IOException {
         // we need to throw error if connect() has not been called
            if (!connected)
                throw new java.lang.Error("DataSource must be connected before it can be started");
            if (started)
                return;
         started = true;
         stream.start(true);
        public void stop() throws IOException {
         if ((!connected) || (!started))
             return;
         started = false;
         stream.start(false);
        public Object [] getControls() {
         return controls;
        public Object getControl(String controlType) {
           try {
              Class  cls = Class.forName(controlType);
              Object cs[] = getControls();
              for (int i = 0; i < cs.length; i++) {
                 if (cls.isInstance(cs))
    return cs[i];
    return null;
    } catch (Exception e) {   // no such controlType or such control
    return null;
    public Time getDuration() {
         return duration;
    public PushBufferStream [] getStreams() {
         return streams;
    hope this helps

  • HT1296 Please Help with problem syncing Safari bookmarks from iPhone to MacBook

    i have an iPhone 5 (7 software) & Macbook Pro 10.9.1.  I have iCloud set to sync Safari in both.  I want the bookmarks on my iPhone to sync onto/be shared with my Macbook but this is not happening.  (I also have an iPad and the Safari bookmarks are automatically syncing from iPhone to iPad)
    Please help!
    Tx
    Pamela

    Hi goddessinrepose!
    Here is an article for you that will help you troubleshoot this issue with your ability to sync your iCloud bookmarks:
    iCloud: Troubleshooting iCloud Bookmarks and Reading List
    http://support.apple.com/kb/ts4001
    Thanks for being a part of the Apple Support Communities!
    Cheers,
    Braden

  • How to call inner class method in one java file from another java file?

    hello guyz, i m tryin to access an inner class method defined in one class from another class... i m posting the code too wit error. plz help me out.
    // test1.java
    public class test1
         public test1()
              test t = new test();
         public class test
              test()
              public int geti()
                   int i=10;
                   return i;
    // test2.java
    class test2
         public static void main(String[] args)
              test1 t1 = new test1();
              System.out.println(t1.t.i);
    i m getting error as
    test2.java:7: cannot resolve symbol
    symbol : variable t
    location: class test1
              System.out.println(t1.t.geti());
    ^

    There are various ways to define and use nested classes. Here is a common pattern. The inner class is private but implements an interface visible to the client. The enclosing class provides a factory method to create instances of the inner class.
    interface I {
        void method();
    class Outer {
        private String name;
        public Outer(String name) {
            this.name = name;
        public I createInner() {
            return new Inner();
        private class Inner implements I {
            public void method() {
                System.out.format("Enclosing object's name is %s%n", name);
    public class Demo {
        public static void main(String[] args) {
            Outer outer = new Outer("Otto");
            I junior = outer.createInner();
            junior.method();
    }

  • Killing a Java process from another Java process

    Hi
    Is there a possible way of sending a SIGINT, SIGKILL, or any other signal from a Java process running in one JVM, to a java process running in a different JVM on the same machine.
    I've the signal handlers written in my process and they do respond to singals (e.g. on pressing Ctrl-C) on the console, but i want to write a separate program that sends this signal to the first process.
    Any ideas?
    Thanks in advance and regards
    Kashif

    The answer, as always, is that Java can't do operating-system-specific things like that, but you can use JNI to do it. However, if your code created the Java process you want to kill, via Process p = Runtime.getRuntime().exec(...), then you can use p.destroy() to kill it.

  • How to Spawn a concurrent program from another Concurrent Program

    Hi,
    I need to write a concurrent program with PL/sql procedure. Inside this procedure, for a cursor data, for each record I need to spawn another concurrent program. How can I do this. Should I call a concurrent program using fnd_request.submit_request?
    Any suggestions?
    Thanks,
    HC

    Correct - you will need to use FND_REQUEST. Pl use the search feature of these forums to find old threads that discuss this topic
    https://forums.oracle.com/forums/search.jspa?threadID=&q=FND_REQUEST+AND+SUBMIT_REQUEST&objID=c3&dateRange=all&userID=&numResults=15
    How To Submit A Concurrent Request Set Using Fnd_Request.Submit_Request          [Document 382791.1]
    Most Commonly Used FND APIs in APPS Customizations          [Document 221549.1]
    HTH
    Srini

  • Launching a java application from another java application

    Hi,
    I'm facing an interesting challenge :-)
    Inside a Java application, I want to start another java application.
    Possible solutions in my list :
    1. Using jakarta commons launcher.
    2. Runtime.exec (make the code platform dependent).
    3. Starting the main method of the other app by create a new Thread inside the current app
    4. I know people did this by calling an ant target from the java application but I don't have
    any sample code, I appreciate any sample code for it.
    Thanks,
    Ali Salehi

    That is an iteresting challenge :)Don't be mean; he's polite, done some investigation and taken the trouble to be clear. The question, presumably, is "has anyone got a different solution or a preference as to which of these is the best?"
    In which case, my advice would be to say that invoking main in a separate thread is fundamentally different from Runtime.exec() because the former would run in the same JVM. Is this what you want? If one app has the other on its classpath then do they need to be separate apps? Could they be modules of a single app?

  • Please help with creating a summary report from data collected in a fillable PDF form.

    I'm sure this has been asked before so I apologize in advance - I'm new to this forum and I'm not quite sure of which section I should be in. If I may just describe a certain scenario of something I am trying to create - could you please point me in the right direction?
    I'm looking to create a summary report/form to help me better organize my patients after each appointment. So data collected from other fillable forms I've created, will lead to the final page to print that will include selections from fillable text boxes or drop down lists, etc to basically summarize each encounter. It should go something like this:
    FORM 1:
    -pt chart #
    -pg age
    -purpose for visit
    -date of visit
    -diagnosis
    -prognosis
    -etc
    SUMMARY page
    On (-date of visit), patient (-pt chart #) arrived with complaint of (-purpose for visit)....
    The diagnosis was determined to be (-diagnosis), treatment to be performed is suggested to be (-treatment) with a (-prognosis) prognosis. Treatment was (accepted or not) and completed on... etc. etc... you get the idea
    Does anyone know how I can do this?
    Thank you all for your time and advice!

    I have downloaded Castor and got some good tutorials, but.......
    There is a problem, when I try to use the Marshaller to get an XML document the following error is reported:
    java.lang.NoClassDefFoundError: org/apache/xml/serialize/XMLSerializer
    I have scanned the Internet looking for a solution, some recommend including Xecers in the Classpath. I downloaded Xerces 2.7.1 and added it to as instructed but this did not work.
    Hope you can help

  • Please help with how to copy CS3 from iMac (Snow Leopard) to MacBook Air (Mavericks)

    I have a 2006 Mac Desktop computer with the CS3 suite on it.  I still have the discs for the suite and would like to move it over to my macbook air.  I tried to just copy the Photoshop file, but that didn't work. Is there an easy way to migrate these files from one mac to another?  My MacBook Air does not have a DVD drive. Ideally, I would like to have these files on both computers, as I believe you can have your purchased programs on 2 computers.  Anyone have a a quick and easy way to make this happen?

    Never, ever migrate. CS installs are "Machine specific", you break licensing doing that.
    Go here: Download CS3 products and download the installer for your suite onto your new Mac.
    Gene

  • Please help with executing the c-shell script by using the exe class

    I try to use the exec class to execute a c-shell script in my java gui program like this. But I don't get anything when clicking on the start button.
    here is my code:
    Runtime r = Runtime.getRuntime();
    r.exec("./DDMReportEvents");
    ./DDMReportEvents is the name of the c-shell script.

    I think Runtime.exec runs DOS batch files, but not Unix shell scripts.
    Try:
    r.exec("csh -c ./DDMReportEvents");
    to get the shell to run the shell script.

Maybe you are looking for