How can my java application get its own PID?

My java application runs under AIX?
The application needs to get its own PID.
There is a possibility to get it by
Runtime.exec("ps -ef | grep <user.name>");
But is there any other alternate possibility?
Any idea would be great appreciated
kind regards

Hello! I found several ways for this in a blog from someone called Igor Minar on
http://net3x.blogspot.com/2007/03/how-java-application-can-discover-its.html
He found several ways:
* Use Java management and monitoring API
ManagementFactory.getRuntimeMXBean().getName();returns something like
1826@localhost
where 1826 is the PID of the JVM process, i.e. my application's process. But this hack is JVM dependent and may not work on JVM's other than Sun's
* Use a shell script to put a property in place that is set to the PID:
exec java -Dpid=$$ -jar myapp.jar* Java Native Interface - cumbersome and platform dependent solution
* Use procfs (Linux solution: read /proc/self, nifty nifty, posted in the comments of the resp. post!)
int pid = Integer.parseInt( ( new File("/proc/self")).getCanonicalFile().getName() );* From another comment: Reflection will work (on Unix): The Process class has a field called pid which can be queried:
static int getPID(Process process) throws IllegalAccessException, IllegalArgumentException,
                                                                  NoSuchFieldException, SecurityException
     Field field = process.getClass().getDeclaredField("pid");
     field.setAccessible(true);
     return field.getInt(process);
}But this solution looks a bit of a kludge to me. I think the /proc/self solution is best - it definitely rox my sox!
Hope this helps!

Similar Messages

  • I am running 4 ipod classica through one computer and one itunes account/profile.  The ipods belong to me, husband and 2 kids.  How can the kids now get their own accounts but keep the stuff I have already downloaded for them?  They have their own laptops

    I am currently running 4 ipod classics through my own account/profile on itunes.  They belong to me, my husband and 2 kids. 
    The kids are getting older now and have their own laptops.  I would like them to have their own itunes accounts as they will be away from home much of the time and will want to make their own puchases. 
    How can I set them up so that they are independent from my account, but not lose the content that I have downloaded for them over the years?  (A lot of content).

    You and your husband can share a store account and still have seperate iCloud accounts for your contacts, bookmarks and stuff like that.  Click here for instructions to make an apple account without entering a credit card.  Make sure you use a different email address for each apple account. 
    Set up your iPhone/iPad whatever using the new account for iCloud.  Then go into settings/store and sign in with your purchasing account, you may need to sign out of the other account.  To the best of my knowledge, your household is allowed to share purchased legally, someone please correct me if I'm wrong.
    Once you each have your own devices set to your own accounts you can set them to backup to that account and it will keep all your contacts seperate.

  • How can my java application fill out an online form

    Hi,
    I am trying to create a Java application that will connect to a URL, fill out the form and submit it.
    How would I go about doing this?
    Thanks in advance,
    Chanie

    I'm doing something exceedingly similar, but I'm not sure how to get it to work, to be honest. Basically, I'm trying to download information from a site that requires a username and password. The html of the site is as follows, as well as my code. Any help would be appreciated!
    <form method="post" action="/cards/FALLON19790309A.php">
    <p>Username:   <input type="text" name="username" size="16" maxlength="16" value=></p>
    <p>Password:   <input type="password" name="password" size="16" maxlength="16"></p>
    <input type="hidden" name="action" value="muffinklezmer">
    <input type="hidden" name="nocache" value="1046986423">
    <input type="submit" value="Log in"></form>
    My code right now looks like this:
    URL playerCard = new URL("http://www.webpage.com");
    URLConnection pcConnection= playerCard.openConnection();     
    pcConnection.setRequestProperty("username","ABCDE");
    pcConnection.setRequestProperty("password","12345");
    BufferedReader in = new BufferedReader(
    new InputStreamReader(
    pcConnection.getInputStream()));
    pcConnection.connect();
    String inputLine = in.readLine();
    while (inputLine != null)
    System.out.println(inputLine);
    inputLine = in.readLine();
    }

  • How can my java application change unix password?

    Hi all,
    Is there any one knows how to change the Unix password from an application? How can i give commands to the shell?
    Thanks

    How can i write a progaram that takes my (old pass,new pass,confirm pass) and change the unix password

  • How can a genericized class determine its own generic type?

    Hi, I have a generecized class:
    class Foo<T> {
        public Class myClass() {
           // basically want to return T.class
    }Is there a way to do this?
    What if Foo implements FooIF, which is also paramterized with T, can I then use this.getClass().getGenericInterfaces() to find ParametrizedType and cast it to class?
    Thanks,
    Konstantin

    Hi, I have a generecized class:
    Is there a way to do this?
    class Foo<T> {
        private Class<T> myClass;
        public Foo(Class<T> t){
             myClass=t;
    }>
    What if Foo implements FooIF, which is also
    paramterized with T, can I then use
    this.getClass().getGenericInterfaces() to find
    ParametrizedType and cast it to class?If you do class Foo<T> implements FooIF<String> then you can get String back (but you don't cast ParametrizedType), otherwise that will just give you "T".

  • When I switch back to an ongoing application, from the switcher, it reverts to its own 'homepage' rather than the stay at the state/stage I left it at. How can I force applications to maintain the current state?

    iPhone 4S with the latest updates 8.1.3 (12B466) installed.
    When I switch back to an ongoing application, from the switcher, it reverts to its own 'homepage' rather than the stay at the state/stage I left it at.
    How can I force applications to maintain the current state?
    I am in the process of getting enough screenshots to demonstrate further.

    ios7 keeps refreshing apps after switching
    solcwd

  • Some how I have deleted the system Preferences application. I had already deleted everything from the trash bend before I realized system pref. was deleted. How can I recover or get it downloaded?

    Somehow I have deleted the system Preferences application. I had already deleted everything from the trash bend before I realized system pref. was deleted. How can I recover or get it downloaded? Everything has been transferred to my new mac pro, but would like to give this old mac to son-in-law.  Can I download system preferences back into this old mac? 
    Sidney Jean Bienvenu

    How Restore Deleted or Missing OS X Components
    A few of the basic OS X installed applications can be restored from the Optional Installs installer located in the Optional installs folder on your Installer DVD.  However, if what you need is not there then follow the instructions below.
    How to Use Pacifist to Restore Deleted or Missing OS X Components
    Insert the OS X Installer DVD into the optical drive.  Use a simple utility like TinkerTool to toggle invisibility so you can see invisible items.  Alternatively, open the Terminal application in your Utilities folder and at the prompt enter the following:
    defaults write com.apple.finder AppleShowAllFiles Yes
    Press RETURN.
    To turn off the display of invisible files repeat the above command substituting No for Yes.
    The install packages are located in the /System/Installation/ folder on the DVD.
    Download the shareware utility Pacifist. Use it to extract a fresh copy of the missing item(s) from the file archives on your OS X installation DVD. The file archives are in the /System/Installations/ folder (use Go to Folder option in the Go menu of the Finder.)
    Here are Four Basic ways to use Pacifist (courtesy of George Orville.)
    Drag a .pkg icon onto the Pacifist window .....proceed to step 7.
    Click on “Open Package ....” and navigate to package desired and click “Open” in the open/save window.....proceed to step 7.
    Insert Mac OS X installer CD and when it mounts, navigate to .... Menu->Go->Go to Folder. In the path field enter or paste ....
    /Volumes/disc name/System/Installation/Packages (where disc name is the name of the CD/DVD that you inserted.)
    Click on the  "Go" button ..... • Drag a .pkg to Pacifist..... proceed to step 7.
    The package you'll need will have to be discovered by trial and error, but for most applications you should start with the Essentials.pkg and/or Additional Essentials.pkg.
    D. Insert your Mac OS X install disk 1 .... and open Pacifist.
    1.          In Pacifist, select "Open Mac OS X Install Packages" ... dialog may appear asking for disk 2, then disk 3 and finally disk 1 again.... {if DVD is not used)...If “Stop Loading” is selected...the procedure will stop!!!
    2a. When loading is complete, a new window appears, click the triangle to display contents of each package...Select item and proceed to step 7.
    2b.          or click the “Find” icon in the Pacifist window and type the name of the software you need.
    3.          In the list that comes back, click the top most entry for the item that you want. ..... that is the one for the English language.
    4.          On the top of the Pacifist window, click “verify” .... you will probably be prompted for your password.
    5.          Enter checks for.... “verify permissions” and “verify file contents.” and click “verify” ....enter password when prompted.... you will get back output which may look like this:
              20 files were scanned. 20 of 20 files were present on the hard disk. 0 of 20 files had file permissions that did not match those specified in the package. 0 of 20 files had checksums that did not match those specified in the package.
    6.          Click “close”. Go to step 7.
    Extract or Install........
    7.          In the Toolbar (upper left), you now have the option to extract or install. Click a file in the lower list and those two icons will be enabled.
    8.          If “Extract to...” is selected.... navigate to the location where the file will be placed, select “choose”, select “extract” in new dialog that appears,authenicate , if prompted, click “OK”.
    9.          In the next dialog, click “Extract”.
    10.          If “Install” is selected... dialog will appear with the location/path of the installed software. Click “Install”
    11.          Type in your password, click “OK”
    Pacifist will begin to extract files.
    12.          In steps 8/10ß.... you also have the choice to “cancel”
    Notes:          Pacifist may find that a file it is installing already exists on the hard disk. Pacifist will present you with an alert panel....
    Stop
    Leave original alone
    Update .....
    Default selection
    Replace .... (Replace option should only be used on full install packages)

  • How to create a window with its own window border other than the local system window border?

    How to create a window with its own window border other than the local system window border?
    For example, a border: a black line with a width 1 and then a transparent line with a width 5. Further inner, it is the content pane.
    In JavaSE, there seems to have the paintComponent() method for the JFrame to realize the effect.

    Not sure why your code is doing that. I usually use an ObjectProperty<Point2D> to hold the initial coordinates of the mouse press, and set it to null on a mouse release. That seems to avoid the dragging being confused by mouse interaction with other nodes.
    import javafx.application.Application;
    import javafx.application.Platform;
    import javafx.beans.property.ObjectProperty;
    import javafx.beans.property.SimpleObjectProperty;
    import javafx.collections.FXCollections;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.geometry.Point2D;
    import javafx.geometry.Pos;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.ChoiceBox;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.AnchorPane;
    import javafx.scene.layout.StackPane;
    import javafx.scene.layout.VBox;
    import javafx.scene.paint.Color;
    import javafx.stage.Stage;
    import javafx.stage.StageStyle;
    import javafx.stage.Window;
    public class CustomBorderExample extends Application {
      @Override
      public void start(Stage primaryStage) {
      AnchorPane root = new AnchorPane();
      root.setStyle("-fx-border-color: black; -fx-border-width: 1px; ");
      enableDragging(root);
      StackPane mainContainer = new StackPane();
        AnchorPane.setTopAnchor(mainContainer, 5.0);
        AnchorPane.setLeftAnchor(mainContainer, 5.0);
        AnchorPane.setRightAnchor(mainContainer, 5.0);
        AnchorPane.setBottomAnchor(mainContainer, 5.0);
      mainContainer.setStyle("-fx-background-color: aliceblue;");
      root.getChildren().add(mainContainer);
      primaryStage.initStyle(StageStyle.TRANSPARENT);
      final ChoiceBox<String> choiceBox = new ChoiceBox<>(FXCollections.observableArrayList("Item 1", "Item 2", "Item 3"));
      final Button closeButton = new Button("Close");
      VBox vbox = new VBox(10);
      vbox.setAlignment(Pos.CENTER);
      vbox.getChildren().addAll(choiceBox, closeButton);
      mainContainer.getChildren().add(vbox);
        closeButton.setOnAction(new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            Platform.exit();
      primaryStage.setScene(new Scene(root,  300, 200, Color.TRANSPARENT));
      primaryStage.show();
      private void enableDragging(final Node n) {
       final ObjectProperty<Point2D> mouseAnchor = new SimpleObjectProperty<>(null);
       n.addEventHandler(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            mouseAnchor.set(new Point2D(event.getX(), event.getY()));
       n.addEventHandler(MouseEvent.MOUSE_RELEASED, new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            mouseAnchor.set(null);
       n.addEventHandler(MouseEvent.MOUSE_DRAGGED, new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            Point2D anchor = mouseAnchor.get();
            Scene scene = n.getScene();
            Window window = null ;
            if (scene != null) {
              window = scene.getWindow();
            if (anchor != null && window != null) {
              double deltaX = event.getX()-anchor.getX();
              double deltaY = event.getY()-anchor.getY();
              window.setX(window.getX()+deltaX);
              window.setY(window.getY()+deltaY);
      public static void main(String[] args) {
      launch(args);

  • Can i purchase encore on its own?

    I am looking to make professional DVD menus to sell.
    My question is wether i can buy Adobe Encore on its own or does it only come in a bundle with other things?

    If you want to do a one time purchase instead of a subscription you may buy Premiere Pro CS6 to get the bundled Encore CS6 Creative Suite 6
    Otherwise, you may subscribe to either all of the Cloud, or just Premiere Pro, to use Encore... which stops working if you stop subscribing
    CS5-thru-CC PPro/Encore tutorial list http://forums.adobe.com/thread/1448923 will help
    The bottom section of the link above has several Adobe links, and other information, on downloading Premiere Pro CS6 and the bundled Encore CS6, and the TWO ADDED downloads for the Encore library content, to author a DVD or BluRay... and the tutorial list includes learning how to use Encore... pay particular attention to the picture in reply 3 at this link - https://forums.adobe.com/thread/1516173

  • How to invoke java application from ABAP

    How to invoke java application from ABAP  ? Suppose I needto execute a EJB wihic is running on my SAP J2EE Enigne from an ABAP Program .
    Thanks,
    Manish

    Hi Manish,
    did you get some further documents concerning "abap program calls ejb"?
    If yes, could you please send me some informations.
    Thank you for your help.
    Kind regards, Patrick.

  • How can i telnet or get access to other LAN members in LAN without using third party software?

    I have admin access to the main  router in our LAN, so how can i telnet or get access to other LAN  members in LAN without using third party software?
    its linksys3500 router and  i login as admin using the gateway address in address bar..
    i  want to access the c drive of my colleague in same subnet in same  office and i know his ip address.but he not configured telnet accept  request.so without it how can i open his telnet port and access him

    I think you are using the wrong terminology. You can browse the hidden share of any pc if you know the ip and have a valid user account on the pc by typing in the following \\computername\c$ or \\ipaddress\c$ . It should prompt you for a user account. You may have to allow this through the windows firewall (or disable it completely).

  • I have admin access to the main router in our LAN, so how can i telnet or get access to other LAN members in LAN without using third party software?

    I have admin access to the main router in our LAN, so how can i telnet or get access to other LAN members in LAN without using third party software?
    its linksys3500 router and  i login as admin using the gateway address in address bar..
    i want to access the c drive of my colleague in same subnet in same office and i know his ip address.but he not configured telnet accept request.so without it how can i open his telnet port and access him

    Duplicate post. 

  • How can i add form of my own to "SAPM07DR"

    i been asked to add form develop by me to the standart program "SAPM07DR" .
    this task came from the need of the implementation
    of the "material management" , assign forms and program.
    now i get the output "ZWE4"  ,
    and i want to assign form of my own  ,
    i tried to add smart form but i get message
    "Errors occurred while processing output"
    so I want to try layout  with  standard program "SAPM07DR" .
    how can i add form of my own to this program

    First, you must copy this program to your own program with "ZSAPM07DR" then copy the include program where the routine pass through the program
    example: entry_we03 -> from include M07DRENT and M07DRAUS
             change this include to ZM07DRENT and ZM07DRAUS
    The next step is binding your form in the program.
    what forms do you use ? Sapscript or Smartforms ?
    in this Program already used Sapscript. You can See there is Open_Form Function in that Program.
    I suggest you to Bind Smartforms.
    IF you use smartforms, Remark All Statement from
    "PERFORM open_form_sammel." to "PERFORM close_form." before endform
    that perform including in M07DRAUS -> FORM lesen_wes USING objky lgortsplit.
    after that put this program to replace the remark :
    data : FMNAME type RS38L_FNAM.
    DATA: ls_control_param      TYPE ssfctrlop.
    set preview parameters
          MOVE 'X' TO ls_control_param-no_dialog.
          MOVE 'X' TO ls_control_param-preview.
          MOVE 'PRINTER'  TO ls_control_param-device.
    *break-point.
    *****Print SmartForms
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
            EXPORTING
              FORMNAME           = TNAPR-SFORM
            IMPORTING
              FM_NAME            = FMNAME
            EXCEPTIONS
              NO_FORM            = 1
              NO_FUNCTION_MODULE = 2
              OTHERS             = 3.
         CALL FUNCTION FMNAME
         EXPORTING
             control_parameters   = ls_control_param
         TABLES
             traptab           = traptab
         EXCEPTIONS
             formatting_error = 1
             internal_error   = 2
             send_error       = 3.
         if sy-subrc NE 0.
    *******message 'Error' type 'S'.
         endif.
    *******End Smartforms
    Hope This Help...

  • How can I test that the ITS is setup right and working?.

    How can I test that the ITS is setup right and working?.
    At present when calling a CRM transaction (BOR object) via the Nav Bar of the Webclient IC I am getting a message box with the title of 'Message from Webpage' and the content saying 'Object expected'.
    I have re-checked the transaction launcher and navigation bar profile setting and these look okay, hence my question regarding the ITS and how we might test that its functional.
    Jason

    I assume that as I also have a call to a URL (website), which is working fine, then the ITS servicer is also working fine.
    That just leads me to know identify why my BOR object is not being called correctly.
    Within the Transaction launcher I have the following settings:
    Entries
    Launch Trans ID: ZZIC1_LT01
    Component set: ALL
    Technical details
    Description: xxxxx
    Class name: ZCL_ZZIC1_LT01
    Statefull: X
    Further Technical details
    Transaction type: BOR Transaction
    Logical system: CMDCLNT600
    BOR Object type: TSTC_UIF
    Method name: EXECUTE
    Transaction Parameters
    Parameter: Object_key
    Value: CRMD_BUS2000115
    Can anyone see any problems with these entries?.
    what's the best way to ensure that 'CRMD_BUS2000115' is a BOR object?. I can run it as a transaction.
    Jason

  • How can i download applications for i phone without error 1009

    how can i download applications for my i phone without error 1009? yahoomessenger, facebook, e books application etc please help me mu i phone has ios 4.0 and i tune10

    https://www.mozilla.org/firefox/all/
    https://www.mozilla.org/thunderbird/all.html
    Full setup of Firefox and Thunderbird can be downloaded from those links instead of getting the online stub installers.

Maybe you are looking for

  • Splitting File Size

    I have to transfer file from one server to another server using MQSeries. I can transfer file size of Maxm.1000kb But i have file size limit of upto 5000kb. Is there any way to split the file size and transfer the file. Can anybody help me. Thanks. A

  • Populate Actual values in Dependent Choice List

    Hi, I have a scenario wherein 3 metadata fields are dependent on each other. Department -- > EmpNames --> EmpID On implementing the dependent choice list, if i select the department, empnames of that department gets displayed. But by default it loads

  • Adobe premiere elements for 2 camera wedding videography

    I am currently a user of Pinnacle studio 12. I do wedding videography part time and find it fairly easy to edit a wedding shot with two camcorders. I place video from the main camcorder on the main track and video from the second camcorder on the ove

  • CS5 Classroom in a Book

    Do you folks recommend getting this book as a reference? I've got the rudiments, with all of your help, and will probably not go through it lesson by lesson. As a reference, is it useful, given we have this forum and the Help sites? Do you find that

  • Where can i download firmware for ipad 3 celullar   wifi ios 5.1.1 ?

    I was update my ipad from ios 5.1.1 to ios 6.0 but i think ios 6 is bad so i want downgrade to ios 5.1.1 again then i search in google there's no one firmware available for ios 5.1.1 celullar + wifi, please help me....