wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Launch Main from current class scope. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Launch Main from current class scope." Watch "Launch Main from current class scope." New topic
Author

Launch Main from current class scope.

Tempora Telora
Ranch Hand

Joined: Jun 20, 2005
Posts: 83
Problem : Class A needs to call Class B with a main function in it. I need to close down class A before Class B runs.

Situation: A has control over a couple of documents I need it to release for B to be able to use. Because of its set up and what I am trying ot do I need to close and launch B. There I do have a batch file for B but I am trying to refrain from using it.

Any ideas on how to do this?

Thanks,
Randy
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Without more technical descriptions than "close down", "runs", "release" and "launch", we won't be able to help.

Note that any code can run a main() method in another class -- it's just a method, and you can go ahead and call it. If there's something you need to do because calling B.main(), can you just do it explicitly in code in A (closing windows? closing files?)


[Jess in Action][AskingGoodQuestions]
Tempora Telora
Ranch Hand

Joined: Jun 20, 2005
Posts: 83
I have B.Main being called in A.function but, Class A has control over ALOT of files and other items that I need to mess around with in class B.

I need to close A.
A MUST BE CLOSED TO LAUNCH B

Then Launch B.

That is all I need to do though I do not know how to do this. I am sure there is a simple solution I just cannot think of it.

Thanks,
Randy
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

In other words, "A" is a tangled mess that exits with a lot of open files and depends on the OS to clean up after it? I would consider fixing A, rather than trying to come up with new hacks to pile on top of it. It's good practice for a program to clean up after itself. Rewriting A cleanly would be good experience.
Tempora Telora
Ranch Hand

Joined: Jun 20, 2005
Posts: 83
I agree with you but this is for a Rapid Release Prototype for a Customer. Functional will be fixed later for right now I need it to just work.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Launch Main from current class scope.