Solved

compiling java each time properties file is changed

Posted on 2007-03-23
11
199 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
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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now