Results 1 to 2 of 2
- 12-06-2008, 05:05 PM #1
Member
- Join Date
- Dec 2008
- Posts
- 1
- Rep Power
- 0
alternative to static initialization blocks
Hi,
I've been asked to modify some code written by someone else. The code currently has a static initialization block that invokes a program and also uses addShutdownHook to exit cleanly. To invoke and close the program you have to pass a file name as an argument. The static block was working perfect here because the user was passing the file name on the command line when he ran the class using the -D option and the name of the variable. They don't want to do that anymore. I won't have the file name until the user invokes a begin(String file) method. So the static initialization is not a good idea anymore. btw, this class doesn't have a main method. Since I'm new to java, I'm not sure which would be the best approach. I read somewhere that a private static method is an alternative to static initialization blocks. Can I create a private static method and move the lines that start and exit the program there and then call it from inside the begin method? :confused:
I will appreciate any help!
Thanks,
- 12-06-2008, 05:51 PM #2
Member
- Join Date
- Jul 2008
- Posts
- 68
- Rep Power
- 0
Similar Threads
-
alternative for ajax
By site4u in forum New To JavaReplies: 6Last Post: 04-28-2011, 01:15 PM -
Any Alternative to Swing?
By Niveditha in forum AWT / SwingReplies: 13Last Post: 06-27-2008, 09:39 AM -
Explicit static initialization with the static clause
By Java Tip in forum java.langReplies: 0Last Post: 04-16-2008, 11:07 PM -
Blocks Language 0.1
By JavaBean in forum Java SoftwareReplies: 0Last Post: 09-22-2007, 11:21 PM -
Task Blocks 0.5
By johnt in forum Java SoftwareReplies: 0Last Post: 08-08-2007, 08:43 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks