I've a normal Java class (neither a JSP nor a Servlet) that performs some processing on files like reading, writing, and executing some executable files. How to know the relative path of each file?
I know about getClass().getResourceStream()
, but this is useful only for reading files. And I know about getServletContext().getRealPath()
but my code is in ordinary Java class not a servlet.
I'd like to do the following
String relativePath = "path/to/exe";
Runtime.getRuntime.exec(relativePath);