troubleshooting Question

refactoring java code

Avatar of Rohit Bajaj
Rohit BajajFlag for India asked on
6 Comments2 Solutions121 ViewsLast Modified:
Following is my main function :
 public static void main(String[] args) throws Exception {
        String env = System.getProperty("FLOCK_APPS_CONFIG");
        int port=0;
        try {
            InputStream in = new FileInputStream(env);
            Properties props = new Properties();
            port = Integer.parseInt(props.getProperty("port"));
        catch (Exception e)
            logger.log(Level.SEVERE,"Error accessing config File : "+env,e);
        AppStart appStart = new AppStart(port);
        try {
        } finally {

Open in new window

I want to know experts comment on this. If i can improve it in some way..
Some things that probably can be changed are :
1) I am assigning int port = 0
which actually does not make any sense as i want the port to be read from a file and if i cannot read it
applications stops.
2) there is one try catch block and one try finally

Is this code fine or there is some improvement scope in it ?

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 2 Answers and 6 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 2 Answers and 6 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004