Logging Java objects and threads. Application sampling.

I am using a laptop to run my application on. It uses windows XP and it is the only application running on that machine. I use TCP and serial port to communicate to other devices. My application is supposed to use up to 300M of memory but apparently it using much more than that. The laptop physical memory size is 512M. I am wondering if there is a way to sample my application periodically. What I mean by that is, after the applications runs I want to run at the same time kind of profiler that every, let us say, 10 minutes logs the number of objects created and what those objects are or what the current ones are. The number of threads running and what are their names. I want to know what is using all of this memory. The memory usage goes up to about 420M. As a result, the application throws out of memory exception. I believe I can get the number of threads running but do not know how to get their names. I need to know all of that so I would go into my code and see where it is happening and try to solve the problem. One of the ways I have in my mind now is to put a print out everywhere I create an object or thread, but that�s very expensive. Any hints or tips could be useful.
Thank you in advance.
P.S.:
I do not want to run a profiler such as JProfiler because the application is running live and I do not have access to it. I want to embed these logs into the application itself and rerun it on a live system.

As a first thought, I'm guessing that you're merely thinking that your program will not exceed 300 megabytes just based on the -Xmx300M command you may be passing your program. This is a max heap size, not the max footprint your program will take. Be aware that this can go beyond the scope of 300 MB....
Now, if you want very detailed information about processes, memory usage, etc, you might be able to keep track of it yourself, but if you want this information from a system-level sort of thing you will not get it, as one of the major points of Java is that it does not care about a lot of system specifics.
Now, if you're really interested in keeping track of threads, I don't see why you could not just write to a log file every time you spawn a new thread of a particular kind.

Similar Messages

  • JDK 1.6 on Solaris. Multiple java processes and thread freezes

    Hi, we've come across a really weird behavior on the Solaris JVM, reported by a customer of ours.
    Our server application consists of multiple threads. Normally we see them all running within a single Java process, and all is fine.
    At some point in time, and only on Solaris 10, it seems that the main Java process starts a second Java process. This is not our code trying to execute some other application/command. It's the JVM itself forking a new copy of itself. I assumed this was because of some JVM behaviour on Solaris that uses multiple processes if the number of threads is > 128. However at the time of spawn there are less than 90 threads running.
    In any case, once this second process starts, some of the threads of the application (incidentally, they're the first threads created by the application at startup, in the first threadgroup) stop working. Our application dumps a list of all threads in the system every ten minutes, and even when they're not working, the threads are still there. Our logs also show that when the second process starts, these threads were not in the running state. They had just completed their operations and were sleeping in their thread pool, in a wait() call. Once the second process starts, jobs for these threads just queue up, and the wait() does not return, even after another thread has done a notify() to inform them of the new jobs.
    Even more interesting, when the customer manually kills -9 the second process, without doing anything in our application, all threads that were 'frozen' start working again, immediately. This (and the fact that this never happens on other OSes) makes us think that this is some sort of problem (or misconfiguration) specific to the Solaris JVM, and not our application.
    The customer initially reported this with JDK 1.5.0_12 , we told them to upgrade to the latest JDK 1.6 update 6, but the problem remains. There are no special JVM switches (apart from -Xms32m -Xmx256m) used. We're really at a dead end here in diagnosing this problem, as it clearly seems to be outside our app. Any suggestion?

    Actually, we've discovered that that's not really what was going on. I still believe there's a bug in the JVM, but the fork was happening because our Java code tries to exec a command line tool once a minute. After hours of this, we get a rogue child process with this stack (which is where we are forking this command line tool once a minute):
    JVM version is 1.5.0_08-b03
    Thread t@38: (state = IN_NATIVE)
    - java.lang.UNIXProcess.forkAndExec(byte[], byte[], int, byte[], int, byte[], boolean, java.io.FileDescriptor, java.io.FileDescriptor, java.io.FileDescriptor) @bci=168980456 (Interpreted frame)
    - java.lang.UNIXProcess.forkAndExec(byte[], byte[], int, byte[], int, byte[], boolean, java.io.FileDescriptor, java.io.FileDescriptor, java.io.FileDescriptor) @bci=0 (Interpreted frame)
    - java.lang.UNIXProcess.<init>(byte[], byte[], int, byte[], int, byte[], boolean) @bci=62, line=53 (Interpreted frame)
    - java.lang.ProcessImpl.start(java.lang.String[], java.util.Map, java.lang.String, boolean) @bci=182, line=65 (Interpreted frame)
    - java.lang.ProcessBuilder.start() @bci=112, line=451 (Interpreted frame)
    - java.lang.Runtime.exec(java.lang.String[], java.lang.String[], java.io.File) @bci=16, line=591 (Interpreted frame)
    - java.lang.Runtime.exec(java.lang.String, java.lang.String[], java.io.File) @bci=69, line=429 (Interpreted frame)
    - java.lang.Runtime.exec(java.lang.String) @bci=4, line=326 (Interpreted frame)
    - java.lang.Thread.run() @bci=11, line=595 (Interpreted frame)There are also several dozen other threads all with the same stack:
    Thread t@32: (state = BLOCKED)
    Error occurred during stack walking:
    sun.jvm.hotspot.debugger.DebuggerException: can't map thread id to thread handle!
         at sun.jvm.hotspot.debugger.proc.ProcDebuggerLocal.getThreadIntegerRegisterSet0(Native Method)
         at sun.jvm.hotspot.debugger.proc.ProcDebuggerLocal.getThreadIntegerRegisterSet(ProcDebuggerLocal.java:364)
         at sun.jvm.hotspot.debugger.proc.sparc.ProcSPARCThread.getContext(ProcSPARCThread.java:35)
         at sun.jvm.hotspot.runtime.solaris_sparc.SolarisSPARCJavaThreadPDAccess.getCurrentFrameGuess(SolarisSPARCJavaThreadPDAccess.java:108)
         at sun.jvm.hotspot.runtime.JavaThread.getCurrentFrameGuess(JavaThread.java:252)
         at sun.jvm.hotspot.runtime.JavaThread.getLastJavaVFrameDbg(JavaThread.java:211)
         at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:50)
         at sun.jvm.hotspot.tools.JStack.run(JStack.java:41)
         at sun.jvm.hotspot.tools.Tool.start(Tool.java:204)
         at sun.jvm.hotspot.tools.JStack.main(JStack.java:58)I'm pretty sure this is because the fork part of the UnixProcess.forkAndExec is using the Solaris fork1 system call, and thus all the Java context thinks all those threads exist, whereas the actual threads don't exist in that process.
    It seems to me that something is broken in UnixProcess.forkAndExec in native code; it did the fork, but not the exec, and this exec thread just sits there forever. And of course, it's still holding all the file descriptors of the original process, which means that if we decide to restart our process, we can't reopen our sockets for listening or whatever else we want to do.
    There is another possibility, which I can't completely rule out: this child process just happened to be the one that was fork'd when the parent process called Runtime.halt(), which is how the Java process exits. We decided to exit halfway through a Runtime.exec(), and got this child process stuck. But I don't think that's what happens... from what I understand that we collected, we see this same child process created at some point in time, and it doesn't go away.
    Yes, I realize that my JVM is very old, but I cannot find any bug fixes in the release notes that claim to fix something like this. And since this only happens once every day or two, I'm reluctant to just throw a new JVM at this--although I'm sure I will shortly.
    Has anyone else seen anything like this?

  • Reflection objects and thread safety

    Hi,
    I believe that I saw that Field and Method objects are thread-safe (i.e., can safely have methods called against a single object instance concurrently from multiple threads), but am having trouble finding such a description in the JDK javadocs static that fact.
    I'm assuming that all thread-specific 'state' would be managed by the Object target passed to methods like invoke()/get()/set() and not on the actual Field and Method objects themselves. Ideally, i'd like to only have to look up fields and methods only once reflectively, and thereafter just use the same reflection object instances to access their target objects at runtime as a performance optimizations - possibly in different threads and at the same time - without having to pay the cost of looking it up again. I should be able to do that providing Method.invoke() is thread safe. Otherwise, i'd probably be forced to call Class.getMethod() to get a new Method object to use against each object instance, which would be more costly both from a memory standpoint (more Method objects) and a lookup-cost perspective.
    Given that lots of existing performance-critical enterprise infrastructure code, such as OR database APIs, IoC frameworks and J2EE containers use reflection to decouple the generic code from any app specific code (from a compile time perspective) as an alternative to code generation, it's surprising that there's no obvious statement about thread safety in these classes. If I look at the source code for Method, it appears to be thread safe, but I can only get so far with this analysis, as the critical code in Method appears to be implemented using a class named 'sun.reflect.MethodAccessor', whose source I don't have access to.
    I know it's possible to invoke a method against multiple objects by calling Method.invoke() against each of the target objects in question. However, there's no mention as to whether it's safe to use a single Method object instance to invoke a method against multiple target object instances at the same time (i.e., from different threads running in parallel). This would fail, for instance, if the Method object had data members that were used to communicate information between internal calls without any synchronization, as the values might be used by one thread while another was changing them.
    Just to clarify (as i've seen some confusion in other forum discussions on this topic):
    I completely understand that the thread safety of a target object's method (read, small 'm') is entirely dependent upon it's implementation and not the mechanism by which it's invoked - i.e., whether a method is invoked by an explicit compiled-in call against an instance of the target object in some Java source file, or indirectly via Method object-based reflection, is immaterial the the method's thread safety.
    What i'm asking about is the thread safety of the Method.invoke() call itself (read, big 'M'). Same question wrt Field.get()/.set() as well. These calls should be thread-safe if they're stateless wrt the Method and Field object instances that they are invoked against.

    In general, if a Java API is silent about multi-threading, it is intended to be thread-safe. See the javadoc for HashMap for an example of an explicit warning.
    It is true that Java code can have bugs that show up only on unusual implementations of the Java memory model, such as relaxed memory model machines. Most (if not all) implementations of the JDK have been deployed principally on platforms with strong memory models. (Perhaps not coincidentally, those are also the machines that have market share.) There are even bugs found occasionally in the JDK core, so draw your own conclusions about the bug-tail of our software stack on systems with relaxed memory models!
    One of the more likely bugs to run into on highly optimized systems is failure of timely initialization of non-final fields in objects which are shared in an unsynchronized manner. See http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html#finalRight and related pages. JDK core programmers (at Sun, to my personal knowledge) take care not to write code with such bugs, but application programmers might.
    And, yes, caching your own Method objects is a good idea, if only because their lookup is generally cumbersome and slow. If you are very performance sensitive, you'll end up generating bytecode "shim" between your callers and the desired target methods. I expect that the http://openjdk.java.net/projects/mlvm/ (an openjdk project we are just starting) will provide some relief for this; stay tuned.
    Finally, since Method objects have no state to speak of (except their "accessible" bit, which is an ahead-of-time configuration), it would be really, really surprising if they could create a race condition of some sort. If you expect race conditions in formally stateless data structures, you are certifiably paranoid. (A normal state on some platforms, hopefully not on Java.)
    For more information about method calls, including reflective methods, see my blog post: http://blogs.sun.com/jrose/entry/anatomy_of_a_call_site
    Best wishes...

  • How to exchange a java object  between two applications using web service?

    Hi,
    I am working with Eclipse 3.2 and the application server is weblogic 10.
    I have two applications, each one works in an instance of the server.
    The first application contains a method called "send " which return a java object.
    The second one contains a method called "receive" which must receive this object.
    The two applications must exchange the object using web service,
    Can you help me please?
    Thanks.

    Have you defined your service class/methods accepting, or returning, the appropriate objects? If so, does the generated WSDL appear to be correct? I have just completed a web service project and found that passing specific objects to be simple, however, I was passing objects which were simply container objects with bean characteristics. Also, might I suggest that you have a play with netbeans. I found that IDE to be great for creating and consuming web services!

  • Java swing and threading issue

    i am trying to update swing components from some thread. at my first try, i noticed this was a disaster. upon further research, i found out about the single-threaded model of swing events (i.e. event dispatching thread).
    i did more research and could NOT find a good example on how to update swing components from other threads. many examples were showing too much.
    can someone post a simple example on here? i just want to see how to properly update a swing component from a non-swing class using threading.

    I think its a simple example:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=621226
    Let us know what you think.

  • Shared object and different application servers - how to resolve this issue

    Dear SDN Members,
    We are occuring a big problem. We create a shared object in a program and after we call in an another one. In central system architecture, it is working well. But on a distributed architecture (4 application servers), we have a dump some times. In fact, the read of the shared object can be occured in the AS 4 but the share object has been created in AS1.
    How to manage this problem to avoid this dump ?
    Dupplicate the shared object in the application servers ?
    Encapsulate different calls with RFC link to only one AS ?
    Any parameters on server or share objects ?
    Thanks a lot for your help,
    Points will be given to right or good answers.
    Br,
    Aurélien

    What is the dump you are getting ?
    AFAIK, "Shared Memory"(SHM) is an area defined in the app server. I am not sure if you can access SHM of a different app server (as in your case trying to access SHM of AS1 from AS4). [http://help.sap.com/abapdocu_70/en/ABENSHARED_MEMORY_GLOSRY.htm]
    In this case you can opt for "DataBase Clusters". Relevant ABAP statements: [IMPORT|http://help.sap.com/abapdocu_70/en/ABAPIMPORT_MEDIUM.htm#!ABAP_ALTERNATIVE_4@4@]/[EXPORT|http://help.sap.com/abapdocu_70/en/ABAPEXPORT_DATA_CLUSTER_MEDIUM.htm#!ABAP_ALTERNATIVE_4@4@] FROM/TO DATABASE.
    Hope this helps.
    BR,
    SUhas

  • Java Object and varray

    hi
    i want to create a java object which maps varray in oracle.i want a solution though SQLData or CustomDatum interfaces.we have a varray of ints.
    arun aithal

    I think you might find a better audience in the JDBC forum Not only that. It is kind of mandatory here to ridicule lesser languages than PL/SQL and SQL and make fun of people not using Oracle RDBMS. ;-)

  • XML to java object AND Performance

    Hi,
    I read some article about marshalling a XML file to Java Object (like Castor, XML Beans projects...)
    To resume: I would like to marshal a XML doc (from XML to Java object. Later I would like to put these objects on a SGBD...). Unfortenaly I suppose that approach is to expensive on term of performance? Supposing that my xml doc contain 100 data's occurances, XML bean woulkd create 100 objects corresponding. My problem is that I don't want that the all 100 objects live in the same time on memory. For example, my code will read sequential, the xml occurances (like a Sax parser), create 10 datas objects (standby), put these in the data base, and destroy these objects before...iteratively create the next 10 objects...
    It is possible ? Can anybody help me?
    Thank

    On the article: Java Architecture for XML Binding (JAXB)
    (http://java.sun.com/developer/technicalArticles/WebServices/jaxb/)
    I found maybe a response?
    "...in other words, you can do a SAX parse of a document and then pass the events to JAXB for unmarshalling. "
    But somebody could help me to write the code to do that?

  • Socket communication failure between Java applet and C++ application

    I have a java applet that connects to a C++ application via Java's ServerSocket and Socket objects. THe C++ application is using the Winsock 2 API. The applet and application are running on an NT workstation (SP 6) and using IE (5.5) For a very simple C++ test applications the communictions work fine. Once more code gets added to the C++ application the portion of the socket that C++ listens to seems to close. Upon performing a recv call the return value is a zero. Microsoft insists this is a sign the Java side has shut down the socket. The Java applet can still receive messages from the C++ app but C++ cannot receive responses from the Java side. Java throws no exceptions and an explicit check of the socket shows no errors. Again, what puzzles me is that it works for simple C++ applications. Are there any known conflicts between Java and C++ in this regard?
    I have inlcuded the basic java code segments below.
    / run Method.
      * This method is called by the Thread.start() method. This
      * method is required for the implementation of the Runnable interface
      * This method sets up the server side socket communication and
      * contiuously loops looking for requests from a external
      * socket.
      * @author Chris Duke
      public void run(){
         // create socket connections
         boolean success = false;
         try {
             cServerSocket = new ServerSocket(cPortID);
             System.out.println("Waiting for client to connect...");
             cClientSocket = cServerSocket.accept();
             System.out.println("Client connected");
             // Create a stream to read from the client
             cInStream = new BufferedReader(new InputStreamReader(
               cClientSocket.getInputStream()));
             // Create a stream to write to the client       
             cOutStream = new PrintWriter(
               cClientSocket.getOutputStream(), true);
             success = true;
         }catch (IOException e) {
             System.out.println("CommSocket:Run - Socket Exception(1) " + e);
             success = false;
         // if the socket was successfully created, keep the thread running
         while (success){
             try{
                // check socket to see if it is still available for reading
                if (cInStream != null && cInStream.ready()){
                    // check for an incoming message
                    String message = ReceiveMessage();
                    // Send message to listeners
                    Event(message);
                if (cInStream == null){
                    success = false;
                    System.out.println("CommSocket:Run - shutdown");
             }catch (IOException e){
                System.out.println("CommSocket:Run - Socket not ready exception");
                break;
    // SendMessage method -
      *  Sends a text message to a connected listener through port specified by portID
      * @author Chris Duke
      * @param  String message - This will be the message sent out through the server
      * socket's port specified by portID.
       public void SendMessage(String message){
          cOutStream.println(message);
          if (cOutStream.checkError() == true)
            System.out.println("SendMessage : Flush = Error");
          else{
            System.out.println("SendMessage : Flush - No Error");
       }

    a very simple C++ test applications the communictions work fine. Once more code gets added to the C++ application the portion of the socket that C++ listens to seems to close.
    This quite strongly implicates the extra code in the C++ App. The firstly thing I would try would be telnet. Try connecting to both versions of the C++ Application and manually reproducing a proper exchange.
    a recv call the return value is a zero. Microsoft insists this is a sign the Java side has shut down the socket.
    A correct implementation of recv should return the number of bytes received, or -1 for an error. A zero return indicates no bytes received not a socket closed/error. This sounds like FUD to me.
    Are there any known conflicts between Java and C++ in this regard?
    I can see no obvious faults, though the code is incomplete, I don't think it's an sockets implementation issue, at either end, it sounds more likely to be a protocol/handshaking bug in the C++ App.

  • Question about java objects and handles?

    Let me see if I can explain what I have. Inside my originating Java code, I create an object, let's call it object A, from a class I that I DON'T have the source for. It's not my class. Object A in turn creates an object, let's call it Object B, from a class I don't have the source for. Then Object A creates another object, let's call it Object C, that I DO have the source for, and passes it the reference to Object B that it created. My question is this: In my originating Java code, how do I get a reference to Object B? Or, how can I get the reference to Object C, which would allow me to get the reference to Object B?
    Hope everyone understands that?

    Thanks for the reply. Perhaps I should have mentioned that Object A does not have a method to return a referenece to Objects B and C. That's my problem. Was just wondering if there is some other way to obtain those refereneces. The reason I mentioned that I don't have the source code for Object A is because if I did, I could obviously write a method that would return me the references.
    I'm not new to Java, nor am I an expert either. I'm pretty well up-to-speed on object oriented design though.
    I'll provide more specifics on my problem just in case there is a solution to my problem. My code (class) is attempting to establish a connection with a mainframe computer through a web server portal using terminal emulation software provided by a 3rd party vendor. They provide an SDK that contains all the java classes necessary to establsih the connection. To establish the connection, you are required to build a java Properties object that contains all the parameters for the connection (host id, etc.) and pass that properties object to the constructor for the "Object A" class. That object actually establishes the session object using the parameters object you pass it. The session gets displayed in a standalone Applet ("Object A" class extends Applet). You can click on the applet, sign in to the system, and do whatever just fine using your keyboard. However, I wish to send commands to the session from my originating java code. The session object has a method to send commands to the session, but to do that, I need a handle to the session object that was created. I don't have that, and it appears they don't provide a method to get that. Looks like the vendor's intent was just for the user to interface with the session/Applet via the keyboard.

  • Business Objects and Adobe / Application to add comments per report line

    Good day,
    Is it possible to use a Business Objects report output and post it into Adobe forms? We would like to use a report output and allow users to comment per report line - online - or is there any other application in Business Objects which will make this possible
    For Example:
    Report Line Comment
    Sales 9999.9999 ______________________________________
    Expenses 99999.99 ______________________________________
    Thank you.

    Hi,
    I would suggest you post your question into the corresponding BusinessObjects client tool forum.
    Ingo

  • Re: Java Images and Threads prob Help!!

    Without going through it in detail the problem may be that you're doing the repaint which you hope will draw the image before the image has completed loading.
    Create your ImageIcon (loading the "xxxx.jpeg" files) during program initialisation. And check the load status of the icon, at least in a test version.

    I still cant get the reqd output. Only the 1st image is dispayed and when i click the second code, the 2nd image doesnt come(the first one does not disappear, and even when i click the code 1 i have to minimize/ maximize the screen, to get the image and after that it does not go for the s2nd image 2 come!! )
    Create your ImageIcon (loading the "xxxx.jpeg" files) during program >>initialisation. And check the load status of the icon, at least in a test version. How do u load the image during initialization??? and can ny1 plz tell me how to get the flashing threads with msgs????

  • Client side event between Java iView and BSP application

    Hi,
    I am developing a BSP iView which listen to event raised by standard SAP HR TeamViewer iView.  The TeamViewer iView raise a event when user click on the employee list. 
    EPCM.raiseEvent { "urn:com.sap.pct.hcm.orgmanagement:CurrentObject", "objectChanged", concatenatedKey);
    My BSP is subscribing to the event and perform the myreceiveEvent function.
    EPCM.subscribeEvent
    ( "urn:com.sap.pct.hcm.orgmanagement:CurrentObject", "objectChanged", myreceiveEvent );
    However, my BSP returns an error message saying that EPCM is undefined.  I know that I have to included the java script file.  I checked with my basis team guy and they said there is not any js file in ICF.  Can someone let me know which file I need to include in my BSP code and where is the file locate?
    Thanks,
    Eric

    Hi Eric,
    > the ICF where the BSP is stored
    > is in the Oracle database
    Eric... the place where the JS fragment - within the BSP - appears, is retrieved by some http request. The script=epcfproxy.js forces the browser to send a http request just to the same relative location the original page came from. Doesn't matter if something is within a database...
    > Do you know how to locate the
    > epcfproxy.js file in the WAS?
    I think:
    > and the epcfproxy.js file is in the zip file
    > that you suggested
    you have found it?! Put it to any place on the BSP server you can access, if you can't set it with relative url, use "/some/.../dir/epcfproxy.js" as location.
    > If I am only EPCM but not EPCMPROXY,
    > do I need to include the epcfproxy.js in my code?
    Have a look at epcfproxy.js. It's no magic at all, you have to call top or parent (just look) and do some minor things. For sure, you can live without the proxy file, you have just to put the neede scripts explicitely on your page, that's not that fine, but it works.
    Hope it helps
    Detlev

  • How to pass Objects from Java App to JavaFX Application

    Hello,
    New to the JavaFX. I have a Java Swing Application. I am trying to use the TreeViewer in JavaFX since it seems to be a bit better to use and less confusing.
    Any help is appreciated.
    Thanks
    I have my Java app calling my treeviewer JavaFX as
    -- Java Application --
    public class EPMFrame extends JFrame {
    Customer _custObj
    private void categoryAction(ActionEvent e)   // method called by Toolbar
            ocsCategoryViewer ocsFX;    //javaFX treeviewer
            ocsFX = new ocsCategoryViewer();    // need to pass in the Customer Object to this Not seeing how to do it.
                                                  // tried ocsFX = new ocsCategoryViewer(_custObj) ;    nothing happened even when set this as a string with a value
    public class ocsCategoryViewer extends Application {
    String _customer;
    @Override
        public void start(Stage primaryStage) {
         TreeView <String> ocsTree;
         TreeItem <String> root , subcat;
      TreeItem <String> root = new TreeItem <String> ("/");
            root.setExpanded(true);
             ocsTree = new TreeView <String> (root);
             buildTree();     // this uses the Customer Object.
            StackPane stkp_root = new StackPane();
            stkp_root.getChildren().add(btn);
            stkp_root.getChildren().add(ocsTree);
            Scene scene = new Scene(stkp_root, 300, 250);
            primaryStage.setTitle("Tree Category Viewer");
            primaryStage.setScene(scene);
            primaryStage.show();
        public static void main(String[] args) {
            _customer = args[0];      // temporarily trying to pass in string.
            launch(args);

    JavaFX and Swing integration is documented by Oracle - make sure you understand that before doing further development.
    What are you really trying to do?  The answer to your question depends on the approach you are taking (which I can't really work out from your question).  You will be doing one of:
    1. Run your Swing application and your JavaFX application as different processes and communicate between them.
    This is the case if you have both a Swing application with a main which you launch (e.g. java MySwingApp) and JavaFX application which extends application which you launch independently (e.g. java MyJavaFXApp).
    You will need to do something like open a client/server network socket between the applications and send the data between them.
    2. Run a Swing application with embedded JavaFX components.
    So you just run java MySwingApp.
    You use a JFXPanel, which is "a component to embed JavaFX content into Swing applications."
    3. Run a Java application with embedded Swing components.
    So you just run java MyJavaFXApp.
    You use a SwingNode, which is "used to embed a Swing content into a JavaFX application".
    My recommendation is:
    a. Don't use approach number one and have separate apps written in Swing and Java - that would be pretty complicated and unwarranted for almost all applications.
    b. Don't mix the two toolkits unless you really need to.  An example of a real need is that you have a huge swing app based upon the NetBeans platform and you want to embed a couple of JavaFX graphs in there.  But if your application is only pretty small (e.g., it took less than a month to write), just choose one toolkit or the other and implement your application entirely in that toolkit.  If your entire application is in Swing and you are just using JavaFX because you think its TreeView is easier to program, don't do that; either learn how to use Swing's tree control and use that or rewrite your entire application in JavaFX.  Reasons for my suggestion are listed here: JavaFX Tip 9: Do Not Mix Swing / JavaFX
    c. If you do need to mix the two toolkits, the answer of which approach to use will be obvious.  If you have a huge Swing app and want to embed one or two JavaFX components in it, then use JFXPanel.  If you have a huge JavaFX app and want to embed one or two Swing components in it, use a SwingNode.  Once you do start mixing the two toolkits be very careful about thread processing, which you are almost certain screw up at least during development, no matter how an experienced a developer you are.  Also sharing the data between the Swing and JavaFX components will be trivial as you are now running everything in the same application within the virtual machine and it is all just Java so you can just pass data around as parameters to constructors and method calls, the same way you usually do in a Java program, you can even use static classes and data references to share data but usually a dependency injection framework is better if you are going to do that - personally I'd just stick to simply passing data through method calls.

  • Accessing Java Object with out any application servers

    Hi,
    I would be much thankful if any one guide/suggest me how to
    access an java object with out using any application servers.I am
    having an java object which holds dummy data and an mxml file which
    contains some text fields. My plan was to access the java object
    and put the dummy data in the text fields. I am using RemoteObject
    for this. I am not able to proceed further. Please help me.
    Thanks in advance
    Regards
    Karun Kumar

    You can check The Merapi Project it's still in the
    development phase but it'll allow to an AIR app invoke a java class
    and run it as it were inside your app. But that's something you
    can't take into production yet, why don't u wanna use a server
    backend?

Maybe you are looking for