Solved

compiling java each time properties file is changed

Posted on 2007-03-23
11
211 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tomcat startup error 5 166
Delete Android all or certain applications data programmatically 9 147
Java basic valueOf question 1 50
hashmap order 17 61
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

734 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