eclipse - Java jar creation without configuration files in jar -


i crating runnable jar file eclipse, requirement jar don't have properties file log4j.properties , config.properties when creating jar bellow code jar contains both properties file,
so, how can create jar file without properties file?

public class hadoopfilecreation1 {     public final static logger logger = logger.getlogger(hadoopfilecreation1.class);      public string filename = null;      static properties prop = new properties();      public static void main(string[] args) {         try {             system.out.println("---------start------------");             propertyconfigurator.configure("properties/log4j.properties");             hadoopfilecreation1 hfc = new hadoopfilecreation1();             hfc.readproperty();              hfc.writedatfileforhadoop("port", getpropvalues("start_time"));             hfc.writedatfileforhadoop("vlan", getpropvalues("start_time"));              system.out.println("---------end------------");         } catch (exception e) {             e.printstacktrace();             logger.error(e.getmessage());         }      }      public void readproperty() {         try {             prop = new properties();             string propfilename = "properties/config.properties";             file file = new file(propfilename);             fileinputstream inputstream = new fileinputstream(file);             prop.load(inputstream);         } catch (ioexception e) {             e.printstacktrace();             logger.error(e.getmessage());         }     } } 

you have pass file's name argument jar file, take required classes jar file, not configuration files.

public class hadoopfilecreation1 {     public final static logger logger = logger.getlogger(hadoopfilecreation1.class);      public string filename = null;     private string log4jfile=null,configfile=null;     static properties prop = new properties();      public static void main(string[] args) {         try {               log4jfile = args[0];              configfile = args[1];              system.out.println("---------start------------");             propertyconfigurator.configure(log4jfile );             hadoopfilecreation1 hfc = new hadoopfilecreation1();             hfc.readproperty(configfile);              hfc.writedatfileforhadoop("port", getpropvalues("start_time"));             hfc.writedatfileforhadoop("vlan", getpropvalues("start_time"));              system.out.println("---------end------------");          } catch (exception e) {             e.printstacktrace();             logger.error(e.getmessage());         }      }      public void readproperty(string configfile) {         try {             prop = new properties();             string propfilename = configfile;             file file = new file(propfilename);             fileinputstream inputstream = new fileinputstream(file);             prop.load(inputstream);         } catch (ioexception e) {             e.printstacktrace();             logger.error(e.getmessage());         }     } } 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -