Solved

compiling java each time properties file is changed

Posted on 2007-03-23
11
216 Views
Last Modified: 2010-03-31
I have written a java app,which reads a properties file.One of the properties is the location of an input file.
I have compile my code and written a script to run the app.
However each time I change the location of the input file, I need to compile and then run,so that the current file is used.This does not seem to be right.-I thought as long
as you don't make changes to the code there would be no need to compile it over and over again.
0
Comment
Question by:ams7503
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 20

Expert Comment

by:gatorvip
ID: 18781284
>>However each time I change the location of the input file

Explain, please
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 18781360
Make sure you've closed the Properties input stream before you try to read it again
0
 

Author Comment

by:ams7503
ID: 18781383
I cd to the directory where the properties file exists.The properties file has a property called inputfile.
I edit thisfile, by changing the value to some other filename
For eg inputFile=file1.dat- I compile my java code then run the app- the data from file1.dat is used by the java app.
Now,say I changed the filename to file2.dat and did not compile the code and ran the app- the data from file1.dat is still used.I have to compile and then run in order for file2 to be used.
Nothing has changed within any of the java files only an external properties file is being changed and does not need to be compiled.
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:ams7503
ID: 18781563
Thanks for the feedback-
I am not using an input stream to read the properties file, this is how I do it:
Properties props = new Properties();
File data = new File(props.getProperty("inputFile"));
File abbreviations = new File(props.getProperty("abbFile"));
File sic=new File(props.getProperty("sic"))
The only thing that changes in the properties file is the property "inputFile"- I am not sure why consecutive runs is still remembering the old property,unless I compile and then run?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 18781623
>>
Properties props = new Properties();
File data = new File(props.getProperty("inputFile"));
>>

Not possible. 'props' is empty
0
 

Author Comment

by:ams7503
ID: 18781655
sorry- I was wrong.
       java.net.URL url = ClassLoader.getSystemResource("app.properties");
            InputStream is = url.openStream();
            props.load(is);
            is.close();
Then I read the properties-I have already closed the i=InputStream
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 18782341
That's fine. Can you show me the *re*reading code?
0
 

Author Comment

by:ams7503
ID: 18782375
Thanks for the response- I thinkI have figured out what is happening. As a part of the build process I was copying the properties to another location, hence each time  I was editing the properties file, the old file was being used.
Thanks
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 18782387
OK - glad it's working
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 19501793
PAQed with points refunded (50)

Computer101
EE Admin
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question