java - How to access a xml file from a .jar for execute jar from shell_exec php function -


jar apache server php. use shell_exec , give jar file.

but because parse xml file on java class have problem. jar can't access xml.

files

samplesax.java

package phpjavapack;  import java.io.ioexception;  import javax.xml.parsers.parserconfigurationexception; import javax.xml.parsers.saxparser; import javax.xml.parsers.saxparserfactory;  import org.xml.sax.inputsource; import org.xml.sax.saxexception;   public class samplesax {      public static void main(string[] args) throws ioexception, saxexception, parserconfigurationexception {                 /*int i=0;         mybufferedreaderwriter f = new mybufferedreaderwriter();         f.openrfile("dblp.xml");         string sline="";         while ((i<10) && (sline=f.readline()) != null) {             system.out.println(sline);             i++;         }*/          int i=0;              while(i<args.length){          system.out.println("argument's: " + args[0]);         system.setproperty("entityexpansionlimit", "1000000");            saxparserfactory spfac = saxparserfactory.newinstance();         spfac.setnamespaceaware(true);          saxparser saxparser = spfac.newsaxparser();                myhandler handler = new myhandler(args[i]);            inputsource = new inputsource("dblpmini.xml");         is.setencoding("iso-8859-1");         system.out.println("please wait...");         saxparser.parse(is, handler);          system.out.println("---->" + handler.getprofessorspublications());          i++;         }          //system.out.println("#####################################################################################################");         //system.out.println("list of george a. vouros: " + handler.getprofessorspublicationsvalue("george a. vouros"));           //system.out.println(handler.getprofessors());          //handler.createhtmlpage();//emfanizei mia html selida me ta apotelesmata     } } 

myhandler.java

package phpjavapack;  import java.util.arraylist; import java.util.hashtable;  import org.xml.sax.attributes; import org.xml.sax.saxexception; import org.xml.sax.helpers.defaulthandler;  public class myhandler extends defaulthandler {         private publication publication;        protected hashtable<string, arraylist<publication>> professorspublications = new hashtable<string, arraylist<publication>>();        private string temp ;        private arraylist<publication> al;         //private entryld entry = new entryld();  //       public myhandler() { //         super(); //          //         string[] namestable = entry.getnamesinput(); //          //          //         (string name: namestable) { //              //             al = new arraylist<publication>(); //             professorspublications.put(name, al); //         } //          //         system.out.println("hashtable: " + professorspublications); //       }         public myhandler(string authorforsearch){            super();            string name = authorforsearch;             al = new arraylist<publication>();            professorspublications.put(name, al);             system.out.println("hashtable: " + professorspublications);        }         public hashtable<string, arraylist<publication>> getprofessorspublications() {             return professorspublications;        }         public arraylist<publication> getprofessorspublicationsvalue(string author) {             return professorspublications.get(author);        }          public void startelement(string uri, string localname, string qname, attributes attributes) throws saxexception         {            temp = "";            if (qname.equalsignorecase("article") || qname.equalsignorecase("inproceedings")                     || qname.equalsignorecase("proceedings") || qname.equalsignorecase("book")                     || qname.equalsignorecase("incollection") || qname.equalsignorecase("phdthesis")                    || qname.equalsignorecase("mastersthesis") || qname.equalsignorecase("www")) {                publication = new publication();            }        }         public void characters(char[] ch, int start, int length) {            temp = new string(ch, start, length);            system.out.println("----->>>" + temp);            //system.out.print(" <--- temp's start: " + temp + " :my temp's end --> ");        }          public void endelement(string uri, string localname, string qname) throws saxexception         {            if (qname.equalsignorecase("article") || qname.equalsignorecase("inproceedings")                     || qname.equalsignorecase("proceedings") || qname.equalsignorecase("book")                     || qname.equalsignorecase("incollection") || qname.equalsignorecase("phdthesis")                    || qname.equalsignorecase("mastersthesis") || qname.equalsignorecase("www"))             {                for(int i=0; i<publication.getauthors().size(); i++) {                    string authorname = publication.getauthors().get(i);                    if(this.professorspublications.containskey(authorname)) {                        this.publication.settype(localname);                       this.professorspublications.get(authorname).add(publication);                    }                }            }            if(qname.equalsignorecase("author")) {                publication.addauthor(temp);            }            else if(qname.equalsignorecase("title")) {                publication.settitle(temp);            }            else if(qname.equalsignorecase("year")) {                publication.setyear(short.parseshort(temp));            }             else if(qname.equalsignorecase("booktitle")) {                publication.setbooktitle(temp);            }             //string xl = publication.tostring();            //system.out.println(xl);        }   } 

how can give right xml on runnable jar?

thnx

see php exec() command: how specify working directory? - proc_open suggestion/example there best one

see other suggestions @ thread too, chdir


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -