Question

I'm made a Java application that access a web service, gets data, and updates a properties file once, in order to do all it's operations (the app does not access the web service after this call, and keeps it in the properties file instead). It has been planned that this app must be deployed in a Websphere Application Server (WAS), so I want to put the JAR file and the properties file inside an EAR file, assuming that when it is deployed, the JAR and properties file will be inside the same path in the server.

Is there some way I can package the EAR so both the JAR and the properties file are together?

No correct solution

OTHER TIPS

This can be achieved, I do not see any problems here. Do as below:

Package the properties file in the jar and then bundle the jar in the ear.

Using ant you can build the jar with the below command:

<target name="jarx.jar">
    <jar destfile="${dist.dir}/jarx.jar">
        <fileset dir="${classes.dir}">
            <include name="**/*.*"/>
        </fileset>
    </jar>
</target>

How to access the properties file later?

If you want to access the properties file later from any class ClassX, you can simply write

InputStream is = ClassX.getResourceAsStream('/abc.properties');

EDIT:

The second part of the question is already answered here . But I would not advice it because the changes might not immediately reflect or get loaded, without a server start. Not sure on this point.

Also, you need to evaluate what if the jar is a sealed one?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top