Profiling a Java Application

I am relatively new in using a profiler. A large simulation software that I developed requires to be profiled. I want to keep track of the memory usage, CPU usage, time, etc associated with a function call etc. I tried to use Sun Studio 8 to run the profiler. It seems the tutorials on profilers .. all of them ... are intended for Enterprise Applications. All I require is to monitor a general Java application. Could someone answer whether it is possible to profile a java Application?

inside Java Studio Enterprise/Netbeans stack of tools this functionality is implemented as NetBeans Profiler
http://profiler.netbeans.org/
The Profiler hasn't been a part of default Netbeans distribution. The JSE8 is based on NB4.1. Profiler compatible with NB4.1 is an early-access Milestone release, and thus i'd recommend to consider more recent version of the Profiler, the one for NB5.x (though you'd need to install NB5 also).

Similar Messages

  • Profiling a java application with HPjmeter

    I have a java application and i want to identify the performance problems .
    I'm doing a static analyze and a dinamic analyze.
    For the dinamic analyze everything work ok.In the command line i have the options:
    java -agentlib:hjmeter name
    When i want to have a static analyze i have the option:
    java -agentlib:hprof name
    or
    java -Xrunhprof name
    But i get the following error message:
    hprof error:can't create temp heap file: java.hprof.txt.TMP[../../../src/share/demo/jvmti/hprof/hprof_init.c :775]
    My application is running on a HP-UX server:
    java version "1.5.0.03"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0.03-_13_feb_2006_16_39)
    Java HotSpot(TM) Server VM (build 1.5.0.03 jinteg:02.13.06-15:51 PA2.0 (aCC_AP), mixed mode)
    Can anybody help me with some sugestions?
    Thank you!

    inside Java Studio Enterprise/Netbeans stack of tools this functionality is implemented as NetBeans Profiler
    http://profiler.netbeans.org/
    The Profiler hasn't been a part of default Netbeans distribution. The JSE8 is based on NB4.1. Profiler compatible with NB4.1 is an early-access Milestone release, and thus i'd recommend to consider more recent version of the Profiler, the one for NB5.x (though you'd need to install NB5 also).

  • Profiling a remote java application

    First of all i want to say the technologies i use:Eclipse , Java ,
    I made a debug on a remote java application, which runs on a hp ux server.For this i went to debug dialog -> Remote Java application and i introduced:
    - at Hostname:172.26 ......( IP address of the server where the application runs) and at he port number 8000. Works perfect.I started also the agent controller
    with the default configuration(port 10006).
    Then i wanted to make profiling on this application. I installed what i had: EMF 2.3.0 and agent Controller from the address http://www.eclipse.org/tptp/home/downloads/?ver=4.4.0.
    If i run the SampleClient as in the agent controller documentation ,the example work(I received the expected message).
    In Eclipse right click onthe application ->profile as ->open profile dialog .Here i have to fill in :
    - "host name or IP address" (here i think it should be IP of the server:172.26.... where the application runs)
    - "agent controller port" :the default port which is 10006. Then i enter profile.
    But appears an unexpected error:
    org.eclipse.core.runtime.CoreException
    Agent Controller is unavailable under port 10002. Make sure that the service is started and the port number is correct under preferences.
    org.eclipse.tptp.platform.execution.exceptions.AgentControllerUnavailableException
    at org.eclipse.tptp.platform.jvmti.client.internal.launcher.util.AgentControllerDelegate.getConnection(AgentControllerDelegate.java:226)
    at org.eclipse.tptp.platform.jvmti.client.internal.launcher.util.AgentControllerDelegate.getConnection(AgentControllerDelegate.java:71)
    at org.eclipse.tptp.platform.jvmti.client.internal.launcher.TIDelegateHelper.connectToAgentController(TIDelegateHelper.java:388)
    at org.eclipse.tptp.platform.jvmti.client.internal.launcher.TIDelegateHelper.launch(TIDelegateHelper.java:308)
    at org.eclipse.tptp.platform.jvmti.client.internal.launcher.TIJavaLauncherDelegate.launch(TIJavaLauncherDelegate.java:37)
    at org.eclipse.tptp.trace.ui.internal.launcher.core.LauncherUtility.delegateInit(LauncherUtility.java:1153)
    at org.eclipse.tptp.trace.ui.provisional.launcher.PrimaryLaunchDelegate.run(PrimaryLaunchDelegate.java:196)
    at java.lang.Thread.run(Unknown Source)
    Nowhere i introduce the port number 8000. I don't think i filled in the correct information(specially the ports).
    Agent Controller is on.
    If somebody worked with this kind of technology please help me. Is urgent!
    Thank you a lot!!!

    I am using HPjmeter, but i have problems.
    The dinamic analyze works well.The command option was: java -agentlib:jmeter name
    But the static analyze gets errors.The command option was: java -agentlib:hprof name.The error:
    hprof error:can't create temporary file java.hprof.txt.TMP[../../../src/share/demo/jvmti/hprog/hprof_init.c:775]
    What ca be the problem?

  • Profile native code that JAVA application runs

    our application is suffers from a severe memory leak. the application runs on Weblogic that uses the severe container and access Oracle DB.
    the JAVA heap was monitored for several weeks (using the verbose gc flag) and no leak was discovered. we monitored the native heap (by using the pmap command) and we saw that the heap size increasing. therefor we think the problem is in the native code that runs in this process (the major suspect is the OCI, Oracle client).
    after reading the man page of collect and your Article (Profiling Java Appl with Sun Studio 11) I'm confused. I would like to monitor the native heap (with -H option) but in the man page it's written that "Heap profiling is not supported for java programs" so i wheni set the flag -j off i got a warning that this process is java and i might use the -j on.
    please advice what are the values of the flags -j an -H in case of i need to monitor the native code of java application.
    thanks
    yahav

    thanks again for the additional article about the Weblogic.
    in the startManaged script I added the following prefix:
    collect -H on -j off -d /tmp/ java...
    when i typed leaks on er_print, i got a list of possible leaks and allocs.
    some activities were made on the application so i assume that data should be collected. as the size of the experiment folder slightly increased.
    so far we can assume that the data that is relegated to the non java process was collected.
    when i typed leaks again within the er_print tool i got the same results.
    it means that no native heap activities was made.
    is it correct analysis?
    regards the leak that was discovered above, how one can identify the function that cause this leak. i can see calls like:
    malloc, ReadKnownVMs, CreateExecutionEnvironment. this functions relate to the JVM. i would expect to see some trace (allocs) regards the other native code that runs such as the Oracle OCI client.
    I'm suspecting i'm collecting this info.
    is there any other flags to set for such collection? or any other commands in the analysis command

  • URGENT :Error while Running java application in crowntab(linux)

    Hi,
    I have java application on linux machine.
    i created a jar file of my application with all dependencies like oracle drivers etc.
    when i run my jar file from any path using
    java -jar appjar.jar
    its works fine for this or if i add it in .sh file with same comand and run that sh file it also works file.
    Then i try to add it in crowntab entry. and schedule crown.
    It gives me error
    [error]
    Exception in thread "main" java.lang.NoClassDefFoundError: oracle.jdbc.driver.OracleDriver
    at java.lang.Class.initializeClass (libgcj.so.7)
    at java.lang.Class.forName (libgcj.so.7)
    at java.lang.Class.forName (libgcj.so.7)
    at com.soft.mediator.db.DBConnector.init (DBConnector.java:88)
    at com.soft.mediator.db.DBConnector.<init> (DBConnector.java:36)
    at com.soft.mediator.XenerMediator.main (XenerMediator.java:113)
    Caused by: java.lang.ClassNotFoundException: oracle.security.pki.OracleSecretStore not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:/home/abc.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
    at java.net.URLClassLoader.findClass (libgcj.so.7)
    at java.lang.ClassLoader.loadClass (libgcj.so.7)
    at java.lang.ClassLoader.loadClass (libgcj.so.7)
    at java.lang.Class.forName (libgcj.so.7)
    at java.lang.Class.initializeClass (libgcj.so.7)
    ...5 more
    [error]
    i tried to add all path in jar file, class path even on comand line but it gives me same error,
    even i add oracle jar in my path seprately it gives me same error
    any idea what is reason ?

    Thanks for reply
    My problem solved problem was JAVA_HOME.
    Actually on normal shell Jdk version was 1.5, but when it runs my crowntab command linux used jdk 1.4, although JAVA_HOME in etc profile was 1.5 , as it was getting jdk 1.4 so while loading drivers it also includes 1.4 libaries.
    This cause exception in running my crontab entry so i set java_home as well in my shell file and add that shell script in crontab entry

  • Slow starup of Java application - best practices for fine tuning JVM?

    We are having problems with a java application, which takes a long time to startup.
    In order to understand our question we better start with some background info. You will find the question(s) after that.
    Background:
    The setup is as follows:
    In a client-server solution we have a win xp, fat client running java 1.6.0.18.
    (Sun JRE). The fat client containt a lot of GUI, and connects to a server for DB access. Client machines are typical 1 to 3 years old (there are problems even on brand new machines). They have the client version of JRE - standard edition installed (Java SE 6 update 10 or better) Pretty much usual stuff so far.
    We have done a lot of profiling on the client code, and yes we have found parts of our own Java code that needs improving. we are all over this. Server side seems ok with good response times. So far, we havent found anything about shaky net connections or endless loops in the java client code or similiar.
    Still, things are not good. Starting the application takes a long time. too long.
    There are many complicating factors, but here is what we think we have observed:
    There is a problem with cold vs. varm starts of the application. Apparently, after a reboot of the client PC - things are really, really bad - and it takes (sometimes) up to 30-40 secs to start the application (until we arrive at the start GUI in our app).
    If we run our application, close it down, and then restart
    without rebooting, things are a lot better. It then usually takes
    something like 15 - 20 sec. which is "acceptable". Not good, but acceptable,
    Any ideas why?
    I have googled it, and some links seems to suggest that the reason could be disk cache. Where vital jar are already in disk cache on th warm start? Does that make any sense? Virus scanners presumable runs in both cases.
    People still think that 15 - 20 sec in start up on the warm start is an awful long time, even though there is a lot, a lot, of functionality in the application.
    We got a suggestion to use IBMs JRE - as it can do some tricks (not sure what) our SUN JRE cant do concerning the warm and cold start problem. But thats is not an option for us. And noone has come up with any really good suggestions with the SUN JRE so far?
    On the Java Quick Starter (JQS) -
    improves initial startup time for most java applets and applications.
    Which might be helpful? People on the internet seem more interested
    in uninstalling the thing than actually installing it though?
    And it seems very proprietary, where we cant give our Jar files to it?
    We could obviously try to "hide" the problem in some way and make it "seem" quicker. Where perceived performance can be just as good as actual performance. But it does seem a bad solution. So for the cold start we will probably try reading the jar files and thereby have them in disk cache before startup of our application. And see if that helps us.
    Still, ok the cold start is the real killer, but warm start isn't exactly wonderfull either.
    People have suggested that we read more on the JVM and performance.
    java.sun.com.javase/technologies/performance.jsp
    java.sun.com.docs/hotspot/gc5.0/gc_tuning_5.html
    the use of JVM flags "-Xms" "-Xmx" etc etc.
    And here comes the question .. da da ...
    Concerning various suggested reading material.
    it is very much appreciated - but we will like to ask people here - if it is possibe to get more specific pointers. to where the gold might be buried.
    I.e. in a an ideal world we would have time to read and understand all of these documents in depth. However, in this less than ideal world we are also doing a lot of very timeconsuming profiling in our own java code.
    E.g. java garbage collection is is a huge subject - and JVm settings also. Sure, in the end we will probably have to do this all very thoroughly. But for now we are hoping for some heuristics on what other people are doing when facing a problem like ours..?
    Young generation, large memory pages, garbage collection threads ect. all sounds interesting - but what would you start with?
    If you don't have info to decide - what kind of profiling would you be running and then adjust what JVM setting in your trials?
    In this pressed for time scenario. Ignorance is not bliss. But makes it hard to pinpoint the or those JVM parameters to adjust. So some good pointers from experienced JVM "configurators" will be much appreciated!
    Actually, If we can establish that finetuning of these parameters is a good idea, it will certainly also be much easier to allocate the time for doing so. - reading, experimenting etc. in our project.
    So, All in all , what kinds of performance improvements can we hope for? 5 out of 20 secs on the warm start? Or is it 10 % nitpicking? Whats the ball park figure for what we can hope to achieve here given our setup? What do you think based on above?
    Maybe someone out there have done some finetuning of JVM parameters in a similiar PC environments like, with similiar fat clients...? Finetuning so and so - gave 5 secs. So start your work with these one-two parameters?
    Something like that - some best practices? Thats what we are hoping for.
    best wishes
    -Simon

    Thanks for helpful answer from both you and kajbj.
    The app doesn't use shared network drives.
    What are you doing between main starts to get executed and the UI is
    displayed?
    Basicly, Calculating what to show in the UI. Accessing server - not so much, there are some reads from a cache, but the profiling doesnt indicate that it should be a problem. Sure, I could shift the startup time to some other slot, but sofar I havent found a place where the end-user wouldnt be annoyed.> Caching of something would seem most obvious. Normal VM stuff >seems unlikely. With profiling i basicly find that ''everything'' takes a lot longer in the cold start scenario. Some of our local java methods are going to be rewritten following our review. But what else can be tuned?You guys dont think the Java Quick Start approach, with more jars in disk cache will give something? And how should that be done/ what does people do?I.e. For the class loader I read something about
    1.Bootstrap class loader
    2.Extensions class loader
    3.System class loader
    and is wondering if this has something to do with the cold start problem?
    The extensions class loader loads the code in the extensions directories (<JAVA_HOME>/lib/ext
    So, we should move app classes to ext? Put them in one jar file? (We have many). Best practice about that?
    Otherwise it seems to me that it must be about finetuning the JVM?
    I imagine that it is a question about:
    1. the right heap size
    2. the right garbage collection scheme
    Googling heap size for XP
    CHE22 writes:
    You are right; -Xms1600M works well, but -Xms1700M bombs
    Thats one best practice or what?
    On garbage collection, there are numerous posts, and much "masters of Java black art" IMHO, And according to profiling GC is not really that much of a problem anyway? Still,
    Based on my description I was hoping for a short reply like "try setting these two parameters on your xp box, it worked for me" ...or something like that. With no takers on that one, I fear people are saying that there is nothing to be gained there?
    we read:
    [ -Xmx3800m -Xms3800m
    Configures a large Java heap to take advantage of the large memory system.
    -Xmn2g
    Configures a large heap for the young generation (which can be collected in parallel), again taking advantage of the large memory system. It helps prevent short lived objects from being prematurely promoted to the old generation, where garbage collection is more expensive.
    Unless you have problems with pauses, try granting as much memory as possible to the virtual machine. The default size (64MB) is often too small.
    Setting -Xms and -Xmx to the same value increases predictability by removing the most important sizing decision from the virtual machine. On the other hand, the virtual machine can't compensate if you make a poor choice.
    The -XX:+AggressiveHeap+ option inspects the machine resources (size of memory and number of processors) and attempts to set various parameters to be optimal for long-running, memory allocation-intensive jobs]
    So is Setting -Xms and -Xmx and -XX:AggressiveHeap
    best practice? What kind of performance improvement should we expect?
    Concerning JIT:
    I read this one
    [the impact of the JIT compiler is obvious on the graph: at startup the time taken is around 500us for the first few values, then quickly drops to 130us, before falling again to 70us, where it stays for 30 minutes,
    for this specific issue, I greatly improved my performances by configuring another VM argument: I set -XX:CompileThreshold=50]
    The size of the cache can be changed with
    -Xmaxjitcodesize
    This sounds like you should do something with JIT args, but reading
    // We disable the JIT during toolkit initialization. This
    // tends to touch lots of classes that aren't needed again
    // later and therefore JITing is counter-productiive.
    java.lang.Compiler.disable();
    However, finding
    the sweet spots for compilation thresholds has been tricky, so we're
    still experimenting with the recompilation policy. Work on it
    continues.
    sounds like there is no such straigth forward path, it all depends...
    Ok, its good, when
    [Small methods that can be more easily analyzed, optimized, and inlined where necessary (and not inlined where not necessary). Clearly delineated uses of data so that usage patterns and lifetimes are apparent. ]
    but when I read this:
    [The virtual machine is responsible for byte code execution, storage allocation, thread synchronization, etc. Running with the virtual machine are native code libraries that handle input and output through the operating system, especially graphics operations through the window system. Programs that spend significant portions of their time in those native code libraries will not see their performance on HotSpot improved as much as programs that spend most of their time executing byte codes.]
    I have the feeling that we might not able to improve performance that way?
    Any comments?
    otherwise i was wondering about
    -XX:CompileThreshold=50 -Xmaxjitcodesize (large, how large?)
    Somehow, we still feel that someone out there should have experienced similiar problems? But obviously there is no guarantee that the someone should surf by here!
    In c++ we used to just write everything ourselves. Here it does seem to be a question about the right use of other peoples stuff?
    Where you are kind of hoping for a shortcut, so you dont have to read endless number of documents, but can find a short document that actually addresses your problem ... well.
    -Simon
    Edited by: simoncpm on Mar 15, 2010 3:43 PM
    Edited by: simoncpm on Mar 15, 2010 3:53 PM

  • Send short message from Java application on mobile phone to server; http

    Hello!
    My question is: can I send short message from Java application on mobile phone to server - with the use of SMS (WMA) or http connection?
    I found this topic http://forums.sun.com/thread.jspa?threadID=5405431 about: "how to send data from midlet to servlet using doPost method".
    There is also such topic http://forums.sun.com/thread.jspa?threadID=5408046&tstart=0 about: "CLDC and MIDP - sending SMS to server -> Wireless Messaging API (WMA)".
    Please, kindly help me.
    Code from the topic mentioned above, edited by me so that it can be read easily:
    //http://forums.sun.com/thread.jspa?threadID=5405431
    //CLDC and MIDP - Re: how to send data from midlet to servlet using doPost method
    I want to know how to pass the values .
    for examples : this is what i wrote for doGet
    String url = setting.getUrl().toString()"/testProServlet/servlet/UpdateCompanyProfile?userId="+loggedInUserId"&svComp="saveCompHex;
    userId and svComp has the data which is very long so i wanted to use doPost.
    Now i dont know how to do it.
    This is what i have done in doGet (midlet)
    public void saveCompanyProfile(String saveComp,int flag,String blankFieldNm)
         System.out.println("flag===" flag);
         if (flag==1)
              displayAlert("Company Profile Edit",blankFieldNm+" field cannot be blank.",AlertType.ERROR, edCmpRecForm, true);
         else
              String saveCompHex = helper.encodeHexString(saveComp);
              // String saveCompHex =saveComp;
              HttpConnection httpConn = null;
              serverSettings setting = new serverSettings();
              System.out.println("saveCompHex===" saveCompHex);
              String url = setting.getUrl().toString()"/testProServlet/servlet/UpdateCompanyProfile?userId="loggedInUserId"&svComp="saveCompHex;
              System.out.println("url of save company profile:: "+url);
              InputStream is = null;
              OutputStream os = null;
              try {
                   // Open an HTTP Connection object
                   httpConn = (HttpConnection) Connector.open(url);
                   System.out.println("urlMidlet1 save edited company data===::" url.length());
                   // Setup HTTP Request
                   httpConn.setRequestMethod(HttpConnection.POST);
                   httpConn.setRequestProperty("User-Agent","Profile/MIDP-1.0 Confirguration/CLDC-1.0");
                   System.out.println("urlMidlet2===" url);
                   int respCode = httpConn.getResponseCode();
                   System.out.println("respCode edit company profile=====" respCode);
                   if (respCode == httpConn.HTTP_OK)
                        StringBuffer sb = new StringBuffer();
                        os = httpConn.openOutputStream();
                        is = httpConn.openDataInputStream();
                        int chr;
                        while ((chr = is.read()) != -1)
                             sb.append((char) chr);
                        String sResultSvCompanyProfile= sb.toString();
                        System.out.println("+++++++++++++Company sResult+++++++++++++==="sResultSvCompanyProfile);
                        if (resultViewCompanyProfile.trim().equals(""))
                             System.out.println("++++++++++++++If++++++++++++++SaveCompanyProfile===");
                             displayAlert("Login Incorrect","Username and Password incorrect", AlertType.ERROR, mainForm, true);
                        else
                             System.out.println("++++++++++++++Else++++++++++++++SaveCompanyProfile===");
                             //companyProfile();
                             displayAlert1("Information","Company Profile edited successfully", AlertType.INFO, profileMenuScreen, true);
                   else
                        System.out.println("Error in opening HTTP Connection. Error#" respCode);
                        //the line below divided into two lines because it was too long
                        displayAlert("Connection Failed","Cannot connect to server, please contact the Administrator.",
                        AlertType.ERROR, mainForm, false);
              catch(IOException e)
                   e.getMessage();
              finally {
                   if(is!= null)
                        try
                             is.close();
                        catch (IOException e)
                             // TODO Auto-generated catch block
                             e.printStackTrace();
                             displayAlert("Connection Failed","Cannot connect to server, please contact the Administrator.",
                             AlertType.ERROR, mainForm, false);
                   if(os != null)
                        try
                             os.close();
                        catch (IOException e)
                             // TODO Auto-generated catch block
                             e.printStackTrace();
                             displayAlert("Connection Failed","Cannot connect to server, please contact the Administrator.",
                             AlertType.ERROR, mainForm, false);
                   if(httpConn != null)
                        try
                             httpConn.close();
                        catch (IOException e)
                             // TODO Auto-generated catch block
                             e.printStackTrace();
                             displayAlert("Connection Failed","Cannot connect to server, please contact the Administrator.",
                             AlertType.ERROR, mainForm, false);
              } //end finally
         } //end else (?)
    } //end savecompany

    hi,
    SMS API(WMA) is an optional package. It is not a MIDP1.0 or MIDP2.0 api's.
    There are phones which has WMA api with MIDP1.0 support .... Nokia 3650
    Seimens has some phone with their own api's to send sms.Check out seimens site for more info
    BTW, What do you mean buy sending SMS to Server????
    If you want to send message to server you can do it with Http.
    HTH
    phani

  • Using wget in java application

    Hello.
    I want use 'wget' command from my Java application
    for 'wget' i created command as String type.
    Here is it
    String url_str=wget --post-data "year=2009&month=08&day=01&time=0&profile=1&start=0&stop=1000&step=50&par=&format=0&vars=01&vars=02" http://testsite.com/cgi/script.cgi -O /home/user/test_wget.txt
    then i use it in exec method
    try{
    Runtime rt = Runtime.getRuntime();
    Process p = rt.exec(url_str);
    p.waitFor();
    BufferedReader r = new BufferedReader(
    new InputStreamReader(p.getErrorStream()));
    String s;
    while ((s = r.readLine())!=null) {
    System.out.println( s );
    r.close();
    catch (IOException e){
         // TODO Auto-generated catch block
         e.printStackTrace();
    catch ( InterruptedException e ) {
         e.printStackTrace();
    after running the file test_wget.txt hold
    Error
    Wrong key: not alpha/numerical characters
    however, if i use my url_str from Linux command line
    test_wget.txt is hold usefull data.
    So, how working correct with wget from Java application?
    Thanks for any replys

    So, how working correct with wget from Java application?You don't use it; you use Apache HttpClient in stead which can do exactly the same and more without you needing to call platform specific command line tools.
    In any case if you must go down this path, read this article front to back:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • SAP NW 7.0 AS JAVA Application Server Installation in DMZ : Win 2008 SR2

    Dear Experts,
    We are installing two AS JAVA application servers in DMZ (XYZ domain) and the central instance is running outside DMZ (ABC domain). While trying to give the profile path of the CI, in the application server installation, it says that the path cannot be found. We have opened the following ports 54200,54201,54204,54218,54230,3342,3641,3310,3610,8010,8011, and 25.  The installation inside DMZ is run with a user which is part of local administration group. The DB (SQL 2008R2)is running on a different host in a distributed setup.
    Could  someone please let us know if any other port needs to be open to allow communication between the central instance and application server?
    Help is appreciated.
    KP

    If FileSharing disabled, Firewal is open, unable to do ping test. How does the poor App server can access the Path from CI ?
    Please request your network team to open firewal between CI and APP server otherwise, even if you install you might get other below access problems
    1). user's in App server can't update CI
    2). Jobs in App server might run as expected.
    etc...

  • Help about opening a PHP page from a Java application

    Hi,
    I would have some elements to open a PHP page from a little Java application I'm doing. I would like to know the classes I had to use, how to implement them, ...
    In fact, I dial into my application my login, my password, and when I click on by "Connect" button, I must show the PHP page corresponding ti my profile onto the database. Picking up information from the database is not a problem, I know how to use SQL Packages in Java. The problem is to open a new page (IE or Netscape) when clicking on the "Connect" button in my application.
    Thanks a lot for advice me.
    C�dric

    Hi
    This class is from JavaWorld Tip 66 and I've used it to open web pages and files in a browser.
    import java.io.IOException;
    import java.util.*;
    * A simple, static class to display a URL in the system browser.
    * Under Unix, the system browser is hard-coded to be 'netscape'.
    * Netscape must be in your PATH for this to work.  This has been
    * tested with the following platforms: AIX, HP-UX and Solaris.
    * Under Windows, this will bring up the default browser under windows,
    * usually either Netscape or Microsoft IE.  The default browser is
    * determined by the OS.  This has been tested under Windows 95/98/NT.
    * Examples:
    BrowserControl.displayURL("http://www.javaworld.com")
    BrowserControl.displayURL("file://c:\\docs\\index.html")
    BrowserContorl.displayURL("file:///user/joe/index.html");
    * Note - you must include the url type -- either "http://" or
    * "file://".
    public class BrowserControl
         * Display a file in the system browser.  If you want to display a
         * file, you must include the absolute path name.
         * @param url the file's url (the url must start with either "http://"
    or
         * "file://").
        public static void displayURL(String url) throws Exception
            boolean windows = isWindowsPlatform();
            String cmd = null;
            try
                if (windows)
                    // cmd = 'rundll32 url.dll,FileProtocolHandler http://...'
                    cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
                    Process p = Runtime.getRuntime().exec(cmd);
                else
                    // Under Unix, Netscape has to be running for the "-remote"
                    // command to work.  So, we try sending the command and
                    // check for an exit value.  If the exit command is 0,
                    // it worked, otherwise we need to start the browser.
                    // cmd = 'netscape -remote openURL(http://www.javaworld.com)'
                    cmd = UNIX_PATH + " " + UNIX_FLAG + "(" + url + ")";
                    Process p = Runtime.getRuntime().exec(cmd);
                    try
                        // wait for exit code -- if it's 0, command worked,
                        // otherwise we need to start the browser up.
                        int exitCode = p.waitFor();
                        if (exitCode != 0)
                            // Command failed, start up the browser
                            // cmd = 'netscape http://www.javaworld.com'
                            cmd = UNIX_PATH + " "  + url;
                            p = Runtime.getRuntime().exec(cmd);
                    catch(InterruptedException x)
                        System.err.println("Error bringing up browser, cmd='" +
                                           cmd + "'");
                        System.err.println("Caught: " + x);
                        throw x;
            catch(IOException x)
                // couldn't exec browser
                System.err.println("Could not invoke browser, command=" + cmd);
                System.err.println("Caught: " + x);
                throw x;
         * Try to determine whether this application is running under Windows
         * or some other platform by examing the "os.name" property.
         * @return true if this application is running under a Windows OS
        public static boolean isWindowsPlatform()
            String os = System.getProperty("os.name");
            if ( os != null && os.startsWith(WIN_ID))
                return true;
            else
                return false;
         * Simple example.
        public static void main(String[] args)
          try
    //        displayURL("file://c:\\Manual\\Amphibian Accounting Help Test 3.pdf");
    //        displayURL("http://www.pro7.co.za");
            Properties prop = System.getProperties();
    //        Enumeration enum = prop.propertyNames();
            Enumeration enum = prop.keys();
            while(enum.hasMoreElements())
              enum.nextElement();
          catch(Exception e)
        // Used to identify the windows platform.
        private static final String WIN_ID = "Windows";
        // The default system browser under windows.
        private static final String WIN_PATH = "rundll32";
        // The flag to display a url.
        private static final String WIN_FLAG = "url.dll,FileProtocolHandler";
        // The default browser under unix.
        private static final String UNIX_PATH = "netscape";
        // The flag to display a url.
        private static final String UNIX_FLAG = "-remote openURL";
    }If you find a better solution please let me know!
    Regards
    Michael Williams

  • Want to shutdown solaris 10 using java application

    Greetings all!
    I have been unsuccessful at creating my application to shut down a Solaris 10 server with a java application. I am hoping someone might be able to point me in a good direction here.
    I want to log on as a regular user and run a java application that monitors remote information (UPS battery voltage) and will gracefully shutdown the server if there is a problem. If I run my application as root all is well, except that I am running as root :)
    I can write code to access the shell:
    Process proc = Runtime.getRuntime().exec("ls");
    BufferedReader Input = new BufferedReader(new InputStreamReader(proc.getInputStream()));
    while ((s = Input.readLine()) != null) {out.println(s);}
    But I can't do a "su"?
    I've tried multiple examples out there of code that allows shell communication, and good examples of using Runtime.getRuntime()
    I think the conclusion is that you can't issue a su command via java application.
    I've also tried to telnet from a console to localhost and log in as root - no joy there either.
    Would someone have information that might point me in the right direction to solve this problem? Even better, if there is a sample snippet to go along with any help.
    Thank You very much!
    Ray

    Wow,
    Thank you for the very detailed response! I read the referenced web page last night, I'll read it again today too. RBAC sounds like a pretty complicated administrative tool. Coming from the Win32 domain, most of this security stuff is sadly uncharted territory for me (except for my mac).
    Let me see if I understand your method:
    Create a role, javarole, this role needs Primary Administrator priviliges (in order to invoke "shutdown -y -i5 -g0") only available to root
    Create a powerdown profile, essentially a script:
    this line creates the file:
    # echo "powerdown:::profile to powerdown server:help=powerdown.html" >> /etc/security/prof_attr
    I think this is the actual added script: (instead of the shutdown command just use init 5)
    # chmod 755 /usr/sbin/powerdown
    # cat > /usr/sbin/powerdown <<EOF
    #!/bin/sh
    /usr/sbin/init 5
    EOF
    This line is a bit confusing to me, is it also part of the script?
    # echo "powerdown:suser:cmd:::/usr/sbin/powerdown:uid=0" >> /etc/security/exec_attr
    I see the uid=0 (root)
    It seems obvious to me that I log in a root to create this script, which is the reason it has permission to shutdown...right?
    Also, I tried the su command using runTime.exec("su poweroff"); // a user I created to try poweroff scripts
    It seems that su is generally not available, I will create the role and try to telnet to it.
    What about creating a generic user script that includes the javarole name and password, and then run the script "/usr/sbin/powerdown"
    Yes, it leaves a role password exposed, however it is a very limited role, that is not accessible by a user login, but the turn off script is available to every user?
    Regards,
    Ray

  • Java Application Performance Monitoring - J2EE Transaction Monitoring

    Hi,
    Does SCOM 2012 R2 support J2EE transaction monitoring, ie how application behaves from end users. Apdex scores,response time and throughput , Execution method and SQL queries.I could not find transaction monitoring information in Java MP guide.
    Is that Java managment pack supports monitoring only Tomcat and not weblogic,websphere and jboss on Linux servers,
    Appreciate help in this
    Thanks in advance
    Bharath

    Hi Bharath,
    "Apdex scores,response time and throughput , Execution method and SQL queries."
    You're talking about the metrics similar to those which we have after configuring application monitoring in .NET Application Performance Monitoring (AVIcode APM) template, right? If so, this sort of APM profiling for Java apps introduced in SCOM 2012
    R2. But it's only for Tomcat5.5+ hosted Web Applications:
    http://blogs.technet.com/b/random_happy_dev_thoughts/archive/2014/01/07/system-center-2012-management-pack-for-java-application-performance-monitoring-released.aspx
    If you use another application server rather than Tomcat (WebLogic, WebSphere, JBoss), I would recommend you to take a look at BeanSpy instrumentation itself:
    http://www.systemcentercentral.com/demystifying-jee-app-performance-monitoring-in-opsmgr-2012-jee-faqs/
    Download link:
    http://www.microsoft.com/en-us/download/details.aspx?id=29270
    This is not AVIcode-like APM (AVIcode-like APM relies on it as a prerequisite), but if you are familiar with MBeans structure, you could configure quite interesting monitoring transactions for your java apps:
    http://blogs.inframon.com/post/2012/04/27/WebSphere-monitoring-with-the-JEE-Application-Performance-Monitoring-management-packs.aspx
    http://stefanroth.net/2012/04/10/scom-2012-jee-application-availability-monitor-template/
    Igor Savchenko, VIAcode Consulting LLC (http://www.viacode.com/)

  • Running a JAVA application as a Unix Cron Job

    I'm trying to run a 3rd party java application on a Unix (Solaris) system. I want to run it from a script so that I can put it in the cron schedule. The problem is that it won't run as a pure batch script. It seems to really want a DISPLAY device assigned to the shell, even though it never displays anything to that device. The vendor claims that he is not using any DISPLAY functionality.
    Here's my script;
    #!/bin/sh
    # PARAMETER 1 (%1): name (without .tif)
    # PARAMETER 2 (%2): type (CAMS or MACS)
    # PARAMETER 3 (%3): level (1, 2, or 3)
    export myCP=./Extract.zip:lib/jai_codec.jar:lib/jai_core.jar:lib/mlibwrapper_jai.jar
    export DISPLAY=(some xhost unix workstation's IP address)
    java -classpath $myCP extract.ByteConvertOne $1 $2 $3 > byteconvertone.log 2>&1
    If I run this script with the "export DISPLAY" in place, it runs fine. If I comment out the "export DISPLAY" line, it hangs and will never execute or error out.
    Is there some other redirect, or system property setting I need to change to make this work?
    Help

    only idea is to set system wide the DISPLAY to :0
    for examples in
    /etc/profile :
    export DISPLAY=:0
    btw: AFAIK when you instantiate swing or awt classes they require an X server running and the DISPLAY variable to be set. Perhaps that is a clue, why you need this.

  • Error while running Java application using Crystal Reports 2011

    Hello,
    I would like to ask for your help.
    Environment details:
    Java based standalone application in Development environment.
    Crystal Reports 2011 (no SP applied)
    Oracle 11g ( 32 bit client installed)
    Win7 64 bit OS.
    Workflow:
    While running the java application, which will display the reports I am getting the below mentioned error. I guess that is because I am missing the Crystal runtimes (Correct me if I am wrong).
    I know that CR2011 do not have any sdks/ jar available for deployment. In this case, which runtimes should I be using? Does installing CR2011 be enough in the development box?
    Please provide me the link from which I can download the same.
    Let me know if I need to provide more details on this. Any suggestions are most welcome.
    Thank You.
    Code used:
    reportClientDoc = new ReportClientDocument();
    System.err.println("Opening the Report ");
    reportClientDoc.open(REPORT_PATH, 0);
    // this is where the error or exception is thrown
    _Error: _
    log4j:WARN No appenders could be found for logger (com.crystaldecisions.reports.reportdefinition.ReportDocument).
    log4j:WARN Please initialize the log4j system properly.
    com.crystaldecisions.sdkreport.lib.ReportSDKException: com/businessobjects/reports/jdbinterface/common/DBException---- Error code:-2147467259 Error code name:failed
                    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.<init>(SourceFile:286)
                    at com.businessobjects.sdk.erom.jrc.a.<init>(SourceFile:43)
                    at com.businessobjects.sdk.erom.jrc.ReportAgentFactory.createAgent(SourceFile:46)
                    at com.crystaldecisions.proxy.remoteagent.RemoteAgent.<init>(SourceFile:703)
                    at com.crystaldecisions.proxy.remoteagent.RemoteAgent.a(SourceFile:662)
                    at com.crystaldecisions.proxy.remoteagent.RemoteAgent.a(SourceFile:632)
                    at com.crystaldecisions.sdk.report.application.ClientDocument.if(SourceFile:504)
                    at com.crystaldecisions.sdk.report.application.ClientDocument.open(SourceFile:669)
                    at com.crystaldecisions.reports.sdk.ReportClientDocument.open(Unknown Source)
                    at rp.batch.bo.RpJRCExportReport.runReportExport(RpJRCExportReport.java:517)
                    at rp.batch.bo.RpSchedReportRun.process(RpSchedReportRun.java:163)
                    at rp.batch.bo.RpSchedReportRun.drive(RpSchedReportRun.java:240)
                    at rp.batch.bo.RpSchedReportRun.main(RpSchedReportRun.java:265)
    Caused by: java.lang.NoClassDefFoundError: com/businessobjects/reports/jdbinterface/common/DBException
                    at com.crystaldecisions.reports.queryengine.Session.a2(SourceFile:244)
                    at com.crystaldecisions.reports.datafoundation.DataFoundation.do(SourceFile:376)
                    at com.crystaldecisions.reports.dataengine.dfadapter.DFAdapter.do(SourceFile:111)
                    at com.crystaldecisions.reports.dataengine.datafoundation.CreateDataConnectionCommand.new(SourceFile:81)
                    at com.crystaldecisions.reports.common.CommandManager.a(SourceFile:71)
                    at com.crystaldecisions.reports.common.Document.a(SourceFile:203)
                    at com.businessobjects.reports.reportconverter.v12.e.a(SourceFile:442)
                    at com.businessobjects.reports.reportconverter.v12.e.a(SourceFile:231)
                    at com.businessobjects.reports.reportconverter.v12.d.m(SourceFile:192)
                    at com.businessobjects.reports.reportconverter.v12.f.if(SourceFile:210)
                    at com.businessobjects.reports.reportconverter.v12.V12SaveLoader.a(SourceFile:242)
                    at com.businessobjects.reports.loader.ReportLoader.a(SourceFile:205)
                    at com.businessobjects.reports.sdk.JRCReportLoader.a(SourceFile:137)
                    at com.businessobjects.reports.sdk.JRCReportLoader.a(SourceFile:76)
                    at com.businessobjects.reports.sdk.requesthandler.ReportDocumentRequestHandler.a(SourceFile:136)
                    at com.businessobjects.reports.sdk.JRCCommunicationAdapter.<init>(SourceFile:229)
                    ... 12 more
    Caused by: java.lang.ClassNotFoundException: com.businessobjects.reports.jdbinterface.common.DBException
                    at java.net.URLClassLoader1.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:307)
                    at sun.misc.LauncherAppClassLoader.loadClass(Launcher.java:301)
                    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
                    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
                    ... 28 more

    Help me ...
    Ambient:
    Crystal Reports Viewer 14.0.0.0
    java.vendor = Sun Microsystems Inc.
    java.version = 1.6.0_37
    os.name = Windows NT (unknown)
    os.version = 6.2
    os.arch = amd64
    Exception:
    com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: com.businessobjects.sdk.erom.jrc.ReportAgentFactory---- Error code:-2147215357 [CRSDK00000026] Error code name:internal
              at com.crystaldecisions.sdk.occa.report.lib.ReportSDKException.throwReportSDKException(ReportSDKException.java:112)
              at com.crystaldecisions.proxy.remoteagent.RemoteAgent.createDefaultAgent(RemoteAgent.java:1000)
              at com.crystaldecisions.sdk.occa.report.application.ClientDocument.initRemoteAgent(ClientDocument.java:770)
              at com.crystaldecisions.sdk.occa.report.application.ClientDocument.open(ClientDocument.java:961)
              at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.open(ReportClientDocument.java:226)
              at src.HelloWorldSwing.createAndShowGUI(HelloWorldSwing.java:54)
              at src.HelloWorldSwing.main(HelloWorldSwing.java:24)
    Source:
    import java.awt.BorderLayout;
    import javax.swing.JFrame;
    import com.crystaldecisions.ReportViewer.ReportViewerBean;
    import com.crystaldecisions.sdk.occa.report.application.DatabaseController;
    import com.crystaldecisions.sdk.occa.report.application.OpenReportOptions;
    import com.crystaldecisions.sdk.occa.report.application.ReportClientDocument;
    import com.crystaldecisions.sdk.occa.report.data.IConnectionInfo;
    import com.crystaldecisions.sdk.occa.report.reportsource.IReportSource;
    public class HelloWorldSwing {
               * @param args
              public static void main(String[] args) {
                        HelloWorldSwing pgm = new HelloWorldSwing();
                        try {
                                  pgm.createAndShowGUI();
                        } catch (Exception e) {
                                  e.printStackTrace();
                                  //JOptionPane.showMessageDialog(null, e.toString());
               * @throws Exception
              public void createAndShowGUI() throws Exception {
                        // Make sure we have nice window decorations.
                        JFrame.setDefaultLookAndFeelDecorated(false);
                        // Create and set up the window.
                        JFrame frame = new JFrame("HelloWorldSwing");
                        frame.setTitle("Titolo del Report");
                        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                        ReportViewerBean viewer = new ReportViewerBean();
                        viewer.init(new String[0], null, null, null);
                        ReportClientDocument rpt = new ReportClientDocument();
                        rpt.setReportAppServer(ReportClientDocument.inprocConnectionString); // inproc:jrc
                        rpt.open("Report.rpt", OpenReportOptions._openAsReadOnly);
                        IReportSource rptSource = rpt.getReportSource();
                        viewer.setReportSource(rptSource);
                        frame.getContentPane().add(viewer, BorderLayout.CENTER);
                        frame.setSize(1930, 1030);
                        frame.setVisible(true);
                        viewer.start();

  • Problem while deploying a webdynpro java application in NWDS 7.1 version

    HI All,
            I got the below error when i deploying the  webdynpro java application in NWDS 7.1 version..help me out...........................................
    Exception:
    com.sap.ide.eclipse.deployer.api.APIException: ConnectionException,cause=[Ecc]
    NameNotFoundException.The SAP J2EE ENGINE service 'tcbldeploy_controller' is not available
    because of deployment or down engine( service ).
    Reason: Object not found in lookup of
    tcbldeploy_controller.
         at
    com.sap.ide.eclipse.deployer.dc.ComponentManagerImpl.getDeployProcessor(ComponentManagerImpl
    .java:64)
         at com.sap.ide.eclipse.sdm.threading.DCDeployThread.run(DCDeployThread.java:118)
    Caused by: com.sap.engine.services.dc.api.ConnectionException: [ERROR CODE DPL.DCAPI.1118]
    NameNotFoundException.The SAP J2EE ENGINE service 'tcbldeploy_controller' is not available
    because of deployment or down engine( service ).
    Reason: Object not found in lookup of
    tcbldeploy_controller.
         at
    com.sap.engine.services.dc.api.session.impl.SessionImpl.createCM(SessionImpl.java:320)
         at
    com.sap.engine.services.dc.api.deploy.impl.DeployProcessorImpl.<init>(DeployProcessorImpl.ja
    va:136)
         at
    com.sap.engine.services.dc.api.deploy.impl.DeployProcessorFactoryImpl.createDeployProcessor(
    DeployProcessorFactoryImpl.java:26)
         at
    com.sap.engine.services.dc.api.impl.ComponentManagerImpl.getDeployProcessor(ComponentManager
    Impl.java:46)
         at
    com.sap.ide.eclipse.deployer.dc.ComponentManagerImpl.getDeployProcessor(ComponentManagerImpl
    .java:58)
         ... 1 more
    Caused by: com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Object
    not found in lookup of tcbldeploy_controller.
         at
    com.sap.engine.services.jndi.implserver.ServerContextImpl.lookup(ServerContextImpl.java:649)
         at
    com.sap.engine.services.jndi.implserver.ServerContextRedirectableImpl.lookup(ServerContextRe
    directableImpl.java:80)
         at
    com.sap.engine.services.jndi.implserver.ServerContextImplp4_Skel.dispatch(ServerContextImplp
    4_Skel.java:555)
         at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:319)
         at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:200)
         at
    com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:136
         at
    com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.pro
    cess(ApplicationSessionMessageListener.java:33)
         at
    com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:102)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:172)

    First check is Java stack is running ?
    make sure J2EE_ADMIN user not locked.
    Ans please check password in secure area. check password in secure store should be correct.
    may be you can try with restart of SAP and DB.
    All the best
    regards
    nag

Maybe you are looking for