How to generate a jar file for the java program which has property file
public class Download_logfiles {
/**
* Download_logfiles class has to be public because another class uses the
* Download_logfiles class
*/
private static URL URLObj;
/**
* variable set for the server links from which the log files to be
* downloaded
*/
private static URLConnection connect;
/** Variable for URL connection */
static String filename = "";
/** Variable used for extracting the servers */
static String user = "";
/** Variable used for user id */
static String pass = "";
/** Variable used for password */
static String download = "";
static Set<String> urls = new HashSet<String>();
static Set<String> comp = new HashSet<String>();
static Set<String> envir = new HashSet<String>();
static Properties prop = new Properties();
public static void main(String[] args)
throws IOException { /** program entry point */
System.out.println("argument count:" + args.length + " content:" + args);
if(args.length==0)
{
System.out.println("Please enter the property file via arguments!!!"); /**Go to run configuration and under arguments enter the path **/
System.exit(0);
}
readConfigProperties(args[0]);
configUIParameter();
Hashtable<String, String> loginfo = Validation();
String componentavx = loginfo
.get("component"); /** extract component information */
String environmentProd = loginfo
.get("environment"); /** extract environment information */
config(componentavx, environmentProd);
user = loginfo.get(
"user"); /** extract login information from the property file */
pass = loginfo.get("pass");
try { /** Usage of Try catch handlers */
String currentURL;
Iterator<String> iter = urls.iterator();
System.out.println(iter);
while (iter.hasNext()) { /** Start iterating over URLs */
currentURL = iter.next();
StringTokenizer st = new StringTokenizer(currentURL,
"/."); /**
* The string tokenizer class allows an
* application to break a string into tokens
*/
st.nextToken();
String filePrefix = st.nextToken();
System.out.println("Url: " + currentURL);
boolean moreFilesAvailable = true; /**
* check condition for all
* log files available in
* the server
*/
for (int i = 0; moreFilesAvailable; i++) {
File file = null;
if (i != 0) { /** Handle the condition */
URLObj = new URL(currentURL + filename + "." + i);
} else {
URLObj = new URL(currentURL + filename);
}
You need to pass the path to your file properties into a jvm using -D
-Dname=$pathto yourjar anyargs..
you can get it in your application likethis :
String location = System.getProperty(name);