Results 1 to 8 of 8
  1. #1
    ax2014 is offline Member
    Join Date
    Mar 2014
    Location
    Germany
    Posts
    4
    Rep Power
    0

    Default Running JAR in a JInternalFrame

    Hello Forum,

    I have a question regarding to JAR and JDesktopPane / JInternalFrame.

    Is it possible to load a JAR-File and run it on a JInternalFrame inside another Java-Application?

    At the momemt Iīm experimenting.

    I want to provide a java desktop with java applications that are packed in JARs that should be launchend and run then in a JInternalFrame (or similar).


    Does Java allow this?

    Regards

    Alex

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,390
    Rep Power
    25

    Default Re: Running JAR in a JInternalFrame

    to load a JAR-File and run it
    Not sure what "load" means. A jar file can contain class files that can be executed. If the jar file is on the classpath then the JVM will automatically search it for class files that the program uses. If the jar file is not on the classpath, then it will take a custom classloader to read the class files from the jar file and make them available for the jvm to use.
    Where the code that is referencing the classes in the jar file is executing doesn't make a difference. It can be in your class that extends the JInternalFrame class.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    ax2014 is offline Member
    Join Date
    Mar 2014
    Location
    Germany
    Posts
    4
    Rep Power
    0

    Default Re: Running JAR in a JInternalFrame

    Hello Norm,

    thanks for answer.

    As I understand from your answer it is generally possible to run a JAR inside a JInternalFrame of an application that loaded the JAR (via own class loader for example).

    I found no complete examples to that in the internet.

    So I was not sure about the limits of the JVM and UI-manager, I didnīt know if it pay off to investigate in it.

    Do you know any pages / blogs that treat this topic more detailed?


    Regards

    Alex

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,390
    Rep Power
    25

    Default Re: Running JAR in a JInternalFrame

    Can you explain what "run a jar" means?

    Is this what you are trying to do? The jar file contains classes for a desktop application that uses a GUI window. You want that GUI window to be contained in a JInternalFrame's display.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    ax2014 is offline Member
    Join Date
    Mar 2014
    Location
    Germany
    Posts
    4
    Rep Power
    0

    Default Re: Running JAR in a JInternalFrame

    Hello Norm,

    yes indeed.

    The base idea is to have an interactive java application (letīs say a master window) in that other UI-Applications (JARs) can be run.

    Therefore the idea to use a JDesktopPane with JInternalFrames for the JARs that could be controlled in separate windows.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,390
    Rep Power
    25

    Default Re: Running JAR in a JInternalFrame

    The JInternalFrame would be able to load the classes that the primary GUI class (like a JFrame class) in the jar file used to create a GUI similar to what the class in the jar file loaded. You would need to look at what the code in the jar file does so you could copy it into your class that was going to replace the JFrame class that was used in the jar file.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    3,979
    Rep Power
    5

    Default Re: Running JAR in a JInternalFrame

    In essence what you're describing is a plugin system; you are making your problem description more difficult by referring to "applications", they're not because you want it all to run within ONE application. Your external jars represent individual application components which you can "plug in" into your main application with the JDesktopPane. A more modern term for that is "module" and it is the area of OSGi. OSGi - Wikipedia, the free encyclopedia

    The Netbeans development platform also has support for working with modules. https://netbeans.org/kb/trails/platform.html

    You might also hack something together yourself by implementing your own classloader. Whatever solution you choose, its far from trivial to implement.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  8. #8
    ax2014 is offline Member
    Join Date
    Mar 2014
    Location
    Germany
    Posts
    4
    Rep Power
    0

    Default Re: Running JAR in a JInternalFrame

    Hello forum,

    thanks for your useful information.

    I found some examples with class loaders and plugin-interfaces and JARs and class-loaders in the web.

    I will try it this way: Providing the application components on a package-level in a non runnable JAR file, so that the application can load them and execute them based on a plugin-interface.

    At the moment Iīm testing it on a simple level and it seems to work... letīs see if it will be successfull.

    @gimbal2: Thanks for the hints to the terms application and components.
    My problem description was more on a general level than on a java specific.
    Didnīt want to confuse...

Similar Threads

  1. Replies: 7
    Last Post: 12-18-2011, 04:13 AM
  2. Replies: 1
    Last Post: 09-27-2011, 04:19 PM
  3. Replies: 4
    Last Post: 09-27-2011, 09:20 AM
  4. Replies: 0
    Last Post: 08-09-2011, 06:07 PM
  5. Replies: 0
    Last Post: 08-26-2009, 01:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •