File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes importing one desktop application in other Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "importing one desktop application in other" Watch "importing one desktop application in other" New topic
Author

importing one desktop application in other

abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
i have created two individual desktop application,i want to import one desktop application in another.
help me!
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

abhishek rathur wrote:i have created two individual desktop application,i want to import one desktop application in another.
help me!

Do you mean you want to:
Link one application to another? OR
Use the code available in One of the application?

As far as I know you cannot import applications, but you can import the packages. For that you would have to have a jar of your application and then include it in the classpath of other application.

Mohamed Sanaulla | My Blog
abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
ok if we can not import application,is there any method with the help of which we can invoke other application, what i mean is, in first application i will write a code that will invoke other application.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

abhishek rathur wrote:ok if we can not import application,is there any method with the help of which we can invoke other application, what i mean is, in first application i will write a code that will invoke other application.

You can have a look at ProcessBuilder class to see how you can invoke external applications. Also there's Runtime.exec(), but I would like you to read this article before proceeding.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

FirstApp.main ?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

Maneesh Godbole wrote:FirstApp.main ?

So this means OP would have to import the FirstApp package?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Mohamed Sanaulla wrote:
Maneesh Godbole wrote:FirstApp.main ?

So this means OP would have to import the FirstApp package?

The FirstApp I was referring to, I was imagining a packaged jar file, whose main class was FirstApp.java
If this jar is on the class path, one can definitely invoke FirstApp.main()

Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

Maneesh Godbole wrote:
Mohamed Sanaulla wrote:
Maneesh Godbole wrote:FirstApp.main ?

So this means OP would have to import the FirstApp package?

The FirstApp I was referring to, I was imagining a packaged jar file, whose main class was FirstApp.java
If this jar is on the class path, one can definitely invoke FirstApp.main()



Oh yeah, that was what I was thinking of (when I meant having the Jar on the Classpath). And better than what I suggested later on- Using ProcessBuilder/Runtime.exec().
abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66

You can have a look at ProcessBuilder class to see how you can invoke external applications. Also there's Runtime.exec(), but I would like you to read this article before proceeding.

but i am not creating any exc file,its two individual desktop application.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Did you try invoking FirsAppMainClass.main ?
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3064
    
  33

abhishek rathur wrote:
but i am not creating any exc file,its two individual desktop application.


Please try what Maneesh suggested few posts back.
abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
hi maneesh
i have created two simple java application hello1 and hello2, i have created jar file of hello1 and added that jar file in the hello2 lib and then wrote filename(of_hello1).main(); but its not executing as per required.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

You need to add it to your classpath
http://www.coderanch.com/how-to/java/HowToSetTheClasspath
abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
yeah, i added my jar file to C:\j2sdk\jre\lib\ext but still its showing error
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Unless the main method is programmed to use varargs you need to provide a String[] with the command line arguments. In case you don't need any simply provide an empty array (new String[0]).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
thanks rob prime ,its working
but its not the actual problem, it was just a testing which i was doing, the actual thing is i want to import one desktop application in other,is this possible this way.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41085
    
  43
You need to tell us what you mean by "import one desktop application in other" - it's not a phrase that has a generally accepted meaning.


Ping & DNS - my free Android networking tools app
abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
look its simple, two individual desktop application are there,i want to invoke 2nd desktop application from 1st desktop application.
Suppose if i click a button on 1st desktop application it will invoke the 2nd desktop application.i need to know is this possible
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41085
    
  43
By "invoke", do you mean that you want to start the second application? If so, then Runtime.exec and ProcessBuilder have already been mentioned.

Or should the other application do something? That could still be accommodated by passing command-line arguments to it.
abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
ok so first i have to create a exec file,of my applications,right.can you throw more light on that.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41085
    
  43
Not necessarily. Did you read the article Mohamed linked to? If not, start with that. If you did read it, were you successful in trying the technique?
abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
yeah, i am trying. what i am trying to do,two application are there app1 and app2,i created the jar file of app2 and added it in the lib folder of app1,and also to the class file.
i created a button in appl1, and in event of the appl1 button i am calling app2.main()

but its not working.
abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
Eureka ('');

its working,but for simple desktop application now i have to check it for database based desktop application.
abhishek rathur
Ranch Hand

Joined: Jan 14, 2010
Posts: 66
thank you guys
for all your help.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: importing one desktop application in other
 
Similar Threads
Context Share between 2 Web Apps
Is Java used for Desktop Application in industry?
Data Base DUMP through Java
permutation & combination
Java Flash Integration