Process, help me, real java man

i use following code to execute a command (exceptions are deleted):
String s="java.exe MyClass";
Runtime run=Runtime.getRuntime();
Process pro=run.exec(s);
simple enough, after the code has been executed, we see an interface (i.e. JFrame,if MyClass extends JFrame).
my question is: if user closes MyClass by click close button, in my app, how to know MyClass is destroyed?
very trick, any methods such as Process.waitFor() don't work in the case, because:
1. object Process pro represnts java.exe (not MyClass)
2. MyClass is a process created by java.exe
thx

hi i myself am not a guru but nothing wrong in trying
in the app that i am working i can stop the process in-between
that was possible because i was calling it through a thread
the solution to the problem could be on exit check if the thread is alive() and then you know
new JMenuitem("compile"):
setActionCommand("Compile");
addActionListener(new Compiler());
public class compiler implements ActionListener{
public void actionparformed(ActionEvent e){
String para=e.getActionCommand();new Processer(para);
class Processer implements Runnable{
public processer(String sw){this.s=sw;}
Thread d;
boolean b;              
        public  void start()
            d=new Thread(threada.this);
            d.setPriority(Thread.MAX_PRIORITY-3);
            but.setVisible(true);
            b=true;
            d.start();
public void run()
System.gc();
if(b==true)
  but.setText(" RUNNING "+ d);
  but.setToolTipText("CLICK IF YOU WANT TO STOP THE RUNNING THREAD ");
  but.addActionListener(
          new ActionListener()
              public void actionPerformed(ActionEvent we)
                 try
                 p.destroy();//p is java.lang.Process
                 r.gc();//p is java.lang.Process
                 System.gc();//p is java.lang.Process
                 b=false;
                }catch(Exception ae )
                 {System.out.println(ae);}
                              try{
                                 if (s=="Compile")
                                   new compile();
public void stop()
   try{
   but.setText(" T Stopped .);
   but.setToolTipText("CLICK IF YOU WANT TO STOP THE RUNNING THREAD   |-> "+Thread.currentThread()+"  STOPPED");
                System.gc();
                d=null;
                         }catch(Exception ){}so to all given logic if you could directly dispose the active threads or nullify them it could work or
let us say if the thread is alive then we can show a confirm popup asking if they want the process to end or not
of course u have to handle it in WindowClosingEvvent before your System.exit(0);

Similar Messages

  • Process, please help me, real java man

    i use following code to execute a command (exceptions are deleted):
    String s="java.exe MyClass";
    Runtime run=Runtime.getRuntime();
    Process pro=run.exec(s);
    simple enough, after the code has been executed, we see an interface (i.e. JFrame,if MyClass extends JFrame).
    my question is: if user closes MyClass by click close button, in my app, how to know MyClass is destroyed?
    very trick, any methods such as Process.waitFor() don't work in the case, because:
    1. object Process pro represnts java.exe (not MyClass)
    2. MyClass is a process created by java.exe
    thx

    my question is: if user closes MyClass by click close
    button, in my app, how to know MyClass is destroyed?
    very trick, any methods such as Process.waitFor()
    don't work in the case, because:
    1. object Process pro represnts java.exe (not MyClass)
    2. MyClass is a process created by java.exe
    Obviously you are calling this from a Java program, so you don't need java.exe at all to execute MyClass. Why don't you use:
    String args[] = new String[0];
    MyClass.main(args);If you add some kind of getExitStatus() to MyClass your problems should be solved...
    Thomas

  • Issue about Invoking a BPEL Process with the Generic Java API

    I Invoking a BPEL Process with the Generic Java API and apache axis or axis2
    it turn up a error as follow:
    org.apache.axis2.AxisFault: ORABPEL-08021
    Cannot find partner wsdl.
    parnterLink "BPELProcess1" is not found in process "BPELProcess1" (revision "v2008_11_17__38943").
    Please check the deployment descriptor of the process to find the correct partnerLink name.
         at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512)
         at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370)
         at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
         at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
         at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
         at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:548)
         at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:528)
         at wf.Test_axis2_callws.main(Test_axis2_callws.java:41)
    i can't solve it !
    what's problem ???
    anyone use java code to invoke bpel process successfully..can show me some example?
    thanks
    chan

    Hi,
    Check below link may help you solve your problem.
    http://www.activevos.com/cec/samples/content/sample-invoke/doc/index.html
    Regards

  • Attempt to process file failed with java.lang.StringIndexOutOfBoundsExcep..

    Hello All,
       I am implementing file2file with file going from shared folder to FTPS server.
    I am using TLS and X.509 certificate in file receiver communication channel.
    when I implemented my scenario, this is the error its throwing :
    Success : Connect to FTP server "my ftp address", directory "/TEST/"
    Error : Attempt to process file failed with java.lang.StringIndexOutOfBoundsException: String index out of range: 3
    I know this error is caused when java expects the 3 character length string and if its getting more than that... Does any faced this kindaa problem before...Any help is greatly appreciated....Obviously even points....
    Thanks,
    Ravi

    There is no custom code at all? No mappings, no custom modules, no pre/post processing commands?
    Also, check if you get this error when sending to ftps server without certificate (or with another certificate). It may be an incompatibility issue with certificate.
    Did you import the .pfx (or .p12) file in KeyStorage Service?
    Regards,
    Henrique.

  • Attempt to process file failed with java.io.IOException

    Hi,
    The scenario is from Idoc to flat file and messages are getting processed successfully in XI. but in receiver communication channel error is coming:
    Attempt to process file failed with java.io.IOException: Error during STOR/APPE epilogue: com.sap.aii.adapter.file.ftp.FTPEx: 426 Connection closed; transfer aborted.
    MP: exception caught with cause com.sap.aii.af.ra.ms.api.RecoverableException: Error during STOR/APPE epilogue: com.sap.aii.adapter.file.ftp.FTPEx: 426 Connection closed; transfer aborted.: java.io.IOException: Error during STOR/APPE epilogue: com.sap.aii.adapter.file.ftp.FTPEx: 426 Connection closed; transfer aborted.

    Hi,
    If you are using FTP then,
    1. Make sure that the FTP sever does not have issues with Firewall or a Proxy server access.
    2. Also verify that the specified FTP user ID has the necessary WRITE or overwrite authorization?
    Regards,
    Sarvesh
    ***Reward points, if it helped you.

  • Can i give a process name of executing java class

    hi all,
    what i need is when i execute the class file using java at the command prompt i want to create a separate process of that class. that means when i execute this class i want 2 processes running one is "java" and the other is "The Class To be executed".
    is it possible????
    actually my requirement is that i want only one instance of my class can run at a time.
    please help me
    thanks
    bye

    hi
    actually i can not use the file lock because my application is going to run on Solaris machine and since its a mutiuser platform and every user has a limited access to his data.and any user can run my application so the problem is where one user will write into a file so that other user can also read from the same file.
    can i do it other way using native methods if yes can u elaborate please
    thanks
    bye

  • Starting New process (continous) from another java process

    Hi,
    I am running into a trouble in starting a new java process (continous process it is like daemon process ) from another java process.
    Eg;
    Caller.java runs on one JVM instance, from this Caller.java i need to start a daemon java process ConnectionManager.java (My caller.java should have to know whether ConnectionManager was successfully started as a seperate java process or not)
    Also Caller.java has to stop ConnectionManager.java(which is running as seperate process)
    Any help would be appeciated.
    Thank you very much.

    First of all the design is unusual. Your issue is basically intercommunication between two processes written in java. There are various ways to do that:
    1. Use Persistent system(File/Database) : Easiest but have external dependency.
    2. Use RPC calls both JVM,s little bit complex.
    3. Run new JVM in debug mode and connect on bootstrap port.
    4. Communicate using Sockets.
    Whatever suits you...

  • Help with inventory Java program

    Hello,
    I've been working on this and couldn't get what's the problem is :(
    Can somebody explain to me what would be the problems?
    import java.util.Scanner;
    public class Product
         public static void main(String[] args)
                   Scanner s = new Scanner(System.in);
                   System.out.print("Enter the item number: ");
                   int item = s.nextInt();
                   System.out.print("Enter the product name: ");
                   String product = s.next();
                   System.out.print("Enter the unit: ");
                   int unit = s.nextInt();
                   System.out.print("Enter the price for each unit: ");
                   double price = s.nextDouble();
                   product p = new product(item, product, unit, price);
                   System.out.println("You entered: ");
                   System.out.print("Item: " + p.getItemNumber() + "\nProduct: " + p.getProductName() + "\nUnits: " + p.getUnits() + "\nPricePerUnit: " + p.getPriceUnit() + "\n");
                   System.out.println("Here is the value of inventory :" + p.getPriceInventory());
    class Inventory1
         private int itemNumber;
         private String productName;
         private int Unit;
         private double priceUnit;
         public Inventory1(int itemNumber, String productName, int Unit, double priceUnit)
              this.itemNumber = itemNumber;
              this.productName = productName;
              this.Unit = Unit;
              this.priceUnit = priceUnit;
         public int getItemNumber()
              return itemNumber;
         public void setItemNumber(int itemNumber)
              this.itemNumber = itemNumber;
         public double getPriceUnit()
              return priceUnit;
         public void setPriceUnit(double priceUnit)
              this.priceUnit = priceUnit;
         public String getProductName()
              return productName;
         public void setProductName(String productName)
              this.productName = productName;
         public int getUnit()
              return Unit;
         public void setUnit(int Unit)
              this.Unit = Unit;
         public double getPriceInventory()
              double number = getUnit() * getPriceUnit();
              return number;
    }Build output:
    --------------------Configuration: <Default>--------------------
    java:10: class Product is public, should be declared in a file named Product.java
    public class Product
           ^
    TestProduct.java:23: cannot find symbol
    symbol  : class product
    location: class Product
                product p = new product(item, product, unit, price);
                ^
    TestProduct.java:23: cannot find symbol
    symbol  : class product
    location: class Product
                product p = new product(item, product, unit, price);
                                ^
    3 errors
    Process completed.General output:
    java.lang.NoClassDefFoundError: Product
    Caused by: java.lang.ClassNotFoundException: Product
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    Exception in thread "main"
    Process completed.Help!!
    Thank you in advance

    I adjusted and this time it says:
    Build Output
    --------------------Configuration: <Default>--------------------
    16: cannot find symbol
    symbol  : variable product
    location: class Product
                Product p = new Product(item, product, unit, price);
                                              ^
    16: internal error; cannot instantiate Product.<init> at Product to ()
                Product p = new Product(item, product, unit, price);
                            ^18: cannot find symbol
    symbol  : method getItemNumber()
    location: class Product
                System.out.print("Item: " + p.getItemNumber() + "\nProduct: " + p.getProductName() + "\nUnits: " + p.getUnits() + "\nPricePerUnit: " + p.getPriceUnit() + "\n");
                                             ^
    18: cannot find symbol
    symbol  : method getProductName()
    location: class Product
                System.out.print("Item: " + p.getItemNumber() + "\nProduct: " + p.getProductName() + "\nUnits: " + p.getUnits() + "\nPricePerUnit: " + p.getPriceUnit() + "\n");
                                                                                 ^
    18: cannot find symbol
    symbol  : method getUnits()
    location: class Product
                System.out.print("Item: " + p.getItemNumber() + "\nProduct: " + p.getProductName() + "\nUnits: " + p.getUnits() + "\nPricePerUnit: " + p.getPriceUnit() + "\n");
                                                                                                                    ^
    18: cannot find symbol
    symbol  : method getPriceUnit()
    location: class Product
                System.out.print("Item: " + p.getItemNumber() + "\nProduct: " + p.getProductName() + "\nUnits: " + p.getUnits() + "\nPricePerUnit: " + p.getPriceUnit() + "\n");
                                                                                                                                                        ^
    19: cannot find symbol
    symbol  : method getPriceInventory()
    location: class Product
                System.out.println("Here is the value of inventory :" + p.getPriceInventory());
                                                                         ^
    7 errors
    Process completed.General Output
    --------------------Configuration: <Default>--------------------
    java.lang.NoClassDefFoundError: Product
    Caused by: java.lang.ClassNotFoundException: Product
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    Exception in thread "main"
    Process completed.(>_<)
    I forgot to mention...
    That I need to create a product class that holds the item number, the name of the product, the number of units in stock and the price of each unit (I think I got this part)
    I need to create a Java application that displays the product number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory (the number of units in stock multiplied by the price of each unit).
    Edited by: yodartas on Sep 27, 2008 7:54 PM

  • Can someone pls help me with java on my macbook pro because after i download the mountain lion java has died and i need java to see streaming quotes from stock market

    can someone pls help me with java on my macbook pro because after i download the mountain lion java has died and i need java to see streaming quotes from stock market

    Java is no longer included in Mac OS X by default. If you want Java, you will have to install it.
    However, note that you should think twice before installing Java for such a trivial need as looking at stock market quotes. There are other ways to get that information that don't involve Java, and using Java in your web browser is a HUGE security risk right now. Java has been vulnerable to attack almost constantly for the last year, and has become a very popular, frequently used method for getting malware installed via "drive-by downloads." You really, truly don't want to be using it. See:
    Java is vulnerable… Again?!
    http://java-0day.com

  • Parallel processing of Jobs in Java

    Hi Sun forum Experts,
    we are facing a problem in parallel processing of jobs in java,The jdk version used is 1.4.
    Find the issue analysis as below
    Assume we have TABLE1 as below:  
    1st job completed running and updates the status to OK by running an update query (so STATUS in TABLE1 is OK )---> 1st row  
    2nd job is still running and is in IN (Status in Table) ---> 2nd row  
    3rd job is still running and is in IN (Status in Table) ---> 3rd row  
    4th job is still running and is in IN (Status in Table) ---> 4th row  
    In the meanwhile, the First job has completed the job and hence  status is "OK" now. now we are calling another update query which updates another column in another table(TABLE2) in database.  
    The query is " Update TABLE2 set STATUS="OK" where INIT_NO='123456789' AND NOT EXISTS(SELECT COUNT(*) FROM  TABLE1 WHERE STATUS in('IN','RE'))  
    Hence the subquery is returning 3 rows as count for the inner query execution which skips the updation of the TABLE2.
    {code}
    *The problem is we want all the 4 jobs to be completed first with respect to TABLE1(running a update query)   & Once this is done we need to update another column in another table(TABLE2) in database.*
    i.e as shown below
    {code}
    public void execute(){  
                 dao.updateTable1(); // calls Table1 and updates it to OK. --> This has to be performed for n number for jobs.Finish all job completion and then proceed below.  
                //Once UpdateTable1 is completed ,after this we perform the below step  
                dao.updateTable2(); //calls Table2 and updates it to OK    
    {code}
    how do we handle this scenario in Java,
    Please Note:Version in java is used is 1.4 only
    Deepak                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    yes sir,you are absolutely correct.
    We run 4 jobs to update table1, wait for them all to complete, then update table2   can you please tell me how do we achieve this in java,
    Please note:JDK version is 1.4 which we are using.
    Thanks
    Deepak
    Edited by: Deepak_A_L on Jun 25, 2009 12:58 AM

  • How to create context sensitive help and call the role based help from my Java Project?

    Hello All,
    I am new to Robo Help. I have created a Robo help for my Java Web Applicaion. My application is role base i.e some user's will not see some of the pages of the application. So I want to hide those pages in Robo help as well. I tried creating multiple TOC for different Roles.
    My Question is
    How to call robo Help from my application?(I will be calling using java script. If it is with RoboHelp_CSH.js where can I get that and How to implement it in my project)
    How to implement role based help?
    Thanks,
    Siva.

    I answered that. My point in asking whether it matters was that if it does, then you cannot use content categories and point different users to different categories and not allow them to see the others.
    The alternative, as I said, would be to produce different outputs for each role.
    As it does matter, then using webhelp you will have to use your RoboHelp project to produce a number of outputs, one for each category. Your app would install each webhelp into different folders and when your app determines the user role, you will link to the appropriate help.
    There is another thread running where it has been explained by Willam van Weelden that you can achieve what you want using browser based AIR help. If that form of help can be considered, then the thread is at http://forums.adobe.com/message/4914753?tstart=0#4914753
    Browser based AIR help must be run from a web server. It cannot be installed locally.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • Help in translating JAVA code into CF

    Hi all!  I'm at the end of integrating an in-house calendar with Google calendars and all is working, however, I am stumped as to how implement callback functions.  Here's what I'm trying to do as outlined on http://code.google.com/p/google-api-java-client/source/browse/Batch.wiki?repo=wiki
    What I need to do is this section right here:
    JsonBatchCallback<Calendar> callback = new JsonBatchCallback<Calendar>() {
      public void onSuccess(Calendar calendar, HttpHeaders responseHeaders) {
        printCalendar(calendar);
        addedCalendarsUsingBatch.add(calendar);
      public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) {
        System.out.println("Error Message: " + e.getMessage());
    And then later pass it to:
    client.calendars().insert(entry1).queue(batch, callback);
    I believe I can pass one function by passing just the name of the function, but BatchCallback has two functions.  Is this impossible to do in CF?
    Thanks,
    Ross.

    1. In the future, please use a meaningful subject line, like "loop not performing last iteration." Just saying "Help in my java code" is useless. We know you need help with your Java code, else you wouldn't be posting here.
    2. Repost your code without those annoying superfluous asterisks, and with proper indentation in the section that they are currently polluting. It's too hard to read as-is.

  • HTML Help in a JAVA Application?

    Hope someone can answer this question. I thought that there
    was a way to use HTML Help with a JAVA application, but I am being
    advised by my programmer that I must use JAVA Help. I don't have a
    problem with using RoboHelp to convert my HTML Help file to JAVA
    Help but I do have very serious concerns about the finished output.
    In a word, it is "ugly." Numbers do not align properly with text,
    bullets are huge, bolded words do not come over bolded, text only
    popups appear as huge windows and the list goes on... Any help will
    be greatly appreciated!
    Regarads,
    Fran

    Our Java applications work just fine with webhelp. See the
    topic on my site.

  • How to  code  REAL java

    Whats the best way to right real java code? i did my class, i wrote log in applications and games, but i want to start real stuff like antivirus, or a good aplication that does something
    were do i start

    georgemc wrote:
    jbish wrote:
    georgemc wrote:
    java_jamboree wrote:
    how about writing a java program that displays 'Hello World' on your console.
    I am sure thats real Java.....Your post-count isn't high enough to be sarcastic to other posters ;-)Perhaps not; however, I think my advanced years more than make up for the shortfall : )Erm, either you didn't read it properly, or you've just inadvertently exposed your own sock puppet :-)It's a knee-high.

  • When I try to apply update it tells me firefox is running and when I try to kill firefox it runs suddenly and mmediately after killig process help meeee

    When I try to apply update it tells me firefox is running and when I try to kill firefox it runs suddenly and immediately after killing process help meeee

    hello, in case firefox.exe is always running, this might be a sign of malware active on your pc.
    [[Troubleshoot Firefox issues caused by malware]]
    [[Firefox exe is always running]]

Maybe you are looking for

  • I want to create an eBook for iPad , Mac and "iPhone".

    While I was beginning with creating an eBook with iBookAuthor, I didn't know that the target group iPhone user is missed. I want to create and publish an eBook, which is intended for iPad, Mac and iPhone users. Does somebody know, which software woul

  • Problems with my new E5, help needed

    I just got me a new E5 about a week ago.  Despite reading a lot on this forum, I still have two major issues setting up this device; so I need some help.  Problem number one is that I cannot set up my email.  I have "aol" email that falls under "othe

  • I've reinstalled Windows, how do i get my clickwheel games back onto itunes

    Hi I've got two clickwheel games on my nano - the problem is that I had to reinstall windows, and now my games on my nano - which i paid an extortionate £4.99 each for - aren't showing in itunes. How do I get them back without having to pay again? If

  • Can I make an Ap Tab for my "Group Tab?"

    For instance I grouped all of the blogs I read into a Tab Group and I want an Ap icon that I can click on in the toolbar to access these blogs. Right now they are all showing up in my toolbar, even though I have them "group tabbed." Or I click on the

  • XSLT: How can I explode a single node value multiple times?

    For a given XML tree like this, <?xml version="1.0"?> <offers>   <fcst start_hr="1" end_hr="10" value="100"/> </offers>how can I get an output like this? (I need to explode the value of 100 from hr=1 to hr=10, ten times.) 100,100,100,100,100,100,100,