I do not want to decide on the location of the index in filesystem myself. How do applications in general store any files created while running, is there any kind of store provided by the engine per application basis etc
By default the classes in the java.io
package resolve relative pathnames against the current working directory - i.e. the location in the file system from where the java
command was invoked - that you can get using the user.dir
system property:
String curDir = System.getProperty("user.dir");
But doing this is far from ideal (actually, writing to files is not ideal for portable applications) and I don't recommend this approach but suggest using absolutes filesystem paths and e.g. system properties:
new File(System.getProperty("my.directory" + File.separator + "xxx");
Where the property my.directory
would be set in the app server startup script e.g. assuming JBoss is installed under /opt
, using -Dmy.directory=/var/opt/jboss/<somedir>
to be FHS compliant.
Just keep in mind that:
- Writing to the FS is not ideal for application portability. Prefer writing to a database if possible
- Using
java.io
from EJBs is in theory forbidden.