Java : Cannot convert an URL to a File an Cop this in another folder -


i need in java : want convert url file (the file need .exe file in source-folder, when want create runnable jar-file .exe file in jar-file). then, when succesfully convert this, want copy .exe-file in folder, created before. errors:

java.nio.file.nosuchfileexception: c:\users\the5thbluesky\documents\neue workspace\installertool\bin\installertool\installerexe.exe -> c:\programme\installer\source

url urlexe = installer.class.getresource("installerexe.exe"); file f = urltofile(urlexe);  static file urltofile(url url)  {         file f = null;         try {               f = new file(url.touri());           }            catch(urisyntaxexception e)            {            f = new file(url.getpath());           }        system.out.println(f);         return f;  }  path movesourcepath = paths.get(f.getpath()); path movetargetpath = paths.get("c:/programme/installer/source/"); files.move( movesourcepath, movetargetpath ); 

my whole quellcode:

package installerpack;  import java.awt.borderlayout; import java.awt.eventqueue;  import javax.swing.jframe; import javax.swing.jpanel; import javax.swing.border.emptyborder; import javax.swing.jlabel; import javax.swing.jtextpane;  import javax.swing.jcheckbox; import java.awt.event.mouseadapter; import java.awt.event.mouseevent; import javax.swing.jbutton; import java.awt.event.actionlistener; import java.awt.event.actionevent; import java.io.*; import java.net.urisyntaxexception; import java.net.url;  import javax.swing.joptionpane;  import javax.swing.uimanager; import java.awt.color; import javax.swing.jslider; public class installer extends jframe {  private jpanel contentpane; private char program = 'z'; url urlexe = installer.class.getresource("steam.exe");   /**  * launch application.  */ public static void main(string[] args)  {     try      {         uimanager.setlookandfeel("javax.swing.plaf.nimbus.nimbuslookandfeel");     }      catch (throwable e)      {         e.printstacktrace();     }      eventqueue.invokelater(new runnable()      {         public void run()          {             try              {                 installer frame = new installer();                 frame.setvisible(true);             }              catch (exception e)              {                 e.printstacktrace();             }         }     }); }    /**  * create frame.  * @throws exception   */ public installer() throws exception {      setbackground(color.cyan);     setdefaultcloseoperation(jframe.exit_on_close);     setbounds(100, 100, 600, 564);     contentpane = new jpanel();     contentpane.setbackground(new color(245, 255, 250));     contentpane.setborder(new emptyborder(5, 5, 5, 5));     setcontentpane(contentpane);     contentpane.setlayout(null);      installableprogram[] installableprograms = new installableprogram[10];     boolean[] bol = new boolean[10];     string line;     int index;     index = 0;     system.out.println(urlexe);       try     {         string path = ("c:/programme/installer/source");         url();         file file = new file("c:/users/the5thbluesky/desktop/path.txt");         filereader fr = new filereader(file);         bufferedreader br = new bufferedreader(fr);          // durchlaufen, bis line = null(datei zu ende ist)         for(installableprogram obj : installableprograms)         {             obj.path = br.readline();             system.out.println(obj.path);         }         system.out.println(installableprograms[0].path);         system.out.println(installableprograms[1].path);         system.out.println(installableprograms[2].path);         system.out.println(installableprograms[3].path);         system.out.println(installableprograms[4].path);         system.out.println(installableprograms[5].path);         system.out.println(installableprograms[6].path);         system.out.println(installableprograms[7].path);         system.out.println(installableprograms[8].path);         system.out.println(installableprograms[9].path);        }      catch (ioexception ext)     {         joptionpane.showmessagedialog(null, "das ging wohl schief!");     }       jtextpane txtpndiesesprogrammwird = new jtextpane();     txtpndiesesprogrammwird.seteditable(false);     txtpndiesesprogrammwird.settext("dieses programm wird dazu verwendet, um nach einer auswahl programmen, diese zu installieren. w\u00e4hlen sie dazu unten einfach die programme aus die sie installieren m\u00f6chten und klicken sie dann auf install.");     txtpndiesesprogrammwird.setbounds(37, 12, 460, 58);     contentpane.add(txtpndiesesprogrammwird);      jlabel lbloperainstall = new jlabel("opera wird jetzt installiert");     lbloperainstall.setvisible(false);     lbloperainstall.setbounds(236, 302, 199, 14);     contentpane.add(lbloperainstall);      jlabel lblorigininstall = new jlabel("origin wird jetzt installiert");     lblorigininstall.setvisible(false);     lblorigininstall.setbounds(236, 337, 147, 14);     contentpane.add(lblorigininstall);      jlabel lblteamspeakwirdjetzt = new jlabel("teamspeak wird jetzt installiert");     lblteamspeakwirdjetzt.setvisible(false);     lblteamspeakwirdjetzt.setbounds(236, 369, 199, 16);     contentpane.add(lblteamspeakwirdjetzt);      jlabel lblwinrarwirdjetzt = new jlabel("winrar wird jetzt installiert");     lblwinrarwirdjetzt.setvisible(false);     lblwinrarwirdjetzt.setbounds(236, 399, 181, 16);     contentpane.add(lblwinrarwirdjetzt);      jlabel lblarduinoidewird = new jlabel("arduino ide wird jetzt installiert");     lblarduinoidewird.setvisible(false);     lblarduinoidewird.setbounds(236, 268, 168, 16);     contentpane.add(lblarduinoidewird);      jlabel lblccleanerwirdjetzt = new jlabel("ccleaner wird jetzt installiert");     lblccleanerwirdjetzt.setvisible(false);     lblccleanerwirdjetzt.setbounds(236, 239, 199, 16);     contentpane.add(lblccleanerwirdjetzt);      jlabel lbldevcwirdjetzt = new jlabel("dev-c++ wird jetzt installiert");     lbldevcwirdjetzt.setvisible(false);     lbldevcwirdjetzt.setbounds(236, 209, 219, 16);     contentpane.add(lbldevcwirdjetzt);      jlabel lblgeogebrawirdjetzt = new jlabel("geogebra wird jetzt installiert");     lblgeogebrawirdjetzt.setvisible(false);     lblgeogebrawirdjetzt.setbounds(236, 179, 219, 16);     contentpane.add(lblgeogebrawirdjetzt);      jlabel lblmicrosoftoffice = new jlabel("microsoft office 365 wird jetzt installiert");     lblmicrosoftoffice.setvisible(false);     lblmicrosoftoffice.setbounds(236, 149, 273, 16);     contentpane.add(lblmicrosoftoffice);      jlabel lblsteamwirdjetzt = new jlabel("steam wird jetzt installiert");     lblsteamwirdjetzt.setvisible(false);     lblsteamwirdjetzt.setbounds(236, 119, 168, 16);     contentpane.add(lblsteamwirdjetzt);      jcheckbox checkbxopera = new jcheckbox("opera");     checkbxopera.setforeground(new color(0, 0, 0));     checkbxopera.setbackground(new color(0, 0, 0));     checkbxopera.addactionlistener(new actionlistener()      {         public void actionperformed(actionevent e)          {             if (checkbxopera.isselected())             {                 lbloperainstall.setvisible(true);                 program = '1';             }             else             {                 lbloperainstall.setvisible(false);             }         }      });     checkbxopera.setbounds(37, 298, 97, 23);     contentpane.add(checkbxopera);      jcheckbox checkbxorigin = new jcheckbox("origin\r\n");     checkbxorigin.addactionlistener(new actionlistener() {         public void actionperformed(actionevent e) {             if (checkbxorigin.isselected())             {                 lblorigininstall.setvisible(true);                 program = '2';             }             else             {                 lblorigininstall.setvisible(false);             }         }     });     checkbxorigin.setbounds(37, 333, 97, 23);     contentpane.add(checkbxorigin);      jcheckbox checkbxarduino = new jcheckbox("arduino ide");     checkbxarduino.addactionlistener(new actionlistener() {         public void actionperformed(actionevent e)          {             if (checkbxarduino.isselected())             {                 lblarduinoidewird.setvisible(true);                 program = '3';             }             else             {                 lblarduinoidewird.setvisible(false);             }         }     });     checkbxarduino.setbounds(37, 268, 104, 18);     contentpane.add(checkbxarduino);      jcheckbox checkbxccleaner = new jcheckbox("ccleaner");     checkbxccleaner.addactionlistener(new actionlistener() {         public void actionperformed(actionevent e)          {             if (checkbxccleaner.isselected())             {                 lblccleanerwirdjetzt.setvisible(true);                 program = '4';             }             else             {                 lblccleanerwirdjetzt.setvisible(false);             }         }     });     checkbxccleaner.setbounds(37, 238, 104, 18);     contentpane.add(checkbxccleaner);      jcheckbox checkbxdevc = new jcheckbox("dev- c++\r\n");     checkbxdevc.addactionlistener(new actionlistener() {         public void actionperformed(actionevent e)          {             if (checkbxdevc.isselected())             {                 lbldevcwirdjetzt.setvisible(true);                 program = '5';             }             else             {                 lbldevcwirdjetzt.setvisible(false);             }         }     });     checkbxdevc.setbounds(37, 208, 104, 18);     contentpane.add(checkbxdevc);      jcheckbox checkbxgeogebra = new jcheckbox("geogebra");     checkbxgeogebra.addactionlistener(new actionlistener() {         public void actionperformed(actionevent e)          {             if (checkbxgeogebra.isselected())             {                 lblgeogebrawirdjetzt.setvisible(true);                 program = '6';             }             else             {                 lblgeogebrawirdjetzt.setvisible(false);             }         }     });     checkbxgeogebra.setbounds(37, 178, 104, 18);     contentpane.add(checkbxgeogebra);      jcheckbox checkbxmicrosoft = new jcheckbox("microsoft office 365");     checkbxmicrosoft.addactionlistener(new actionlistener() {         public void actionperformed(actionevent e)          {             if (checkbxmicrosoft.isselected())             {                 lblmicrosoftoffice.setvisible(true);                 program = '7';             }             else             {                 lblmicrosoftoffice.setvisible(false);             }         }     });     checkbxmicrosoft.setbounds(37, 148, 136, 18);     contentpane.add(checkbxmicrosoft);      jcheckbox checkbxsteam = new jcheckbox("steam");     checkbxsteam.addactionlistener(new actionlistener() {         public void actionperformed(actionevent e)          {             if (checkbxsteam.isselected())             {                 lblsteamwirdjetzt.setvisible(true);                 program = '8';             }             else             {                 lblsteamwirdjetzt.setvisible(false);             }         }     });     checkbxsteam.setbounds(37, 118, 104, 18);     contentpane.add(checkbxsteam);      jcheckbox checkbxteamspeak = new jcheckbox("teamspeak");     checkbxteamspeak.addactionlistener(new actionlistener() {         public void actionperformed(actionevent e)          {             if (checkbxteamspeak.isselected())             {                 lblteamspeakwirdjetzt.setvisible(true);                 program = '9';             }             else             {                 lblteamspeakwirdjetzt.setvisible(false);             }         }     });     checkbxteamspeak.setbounds(37, 368, 104, 18);     contentpane.add(checkbxteamspeak);      jcheckbox checkbxwinrar = new jcheckbox("winrar");     checkbxwinrar.addactionlistener(new actionlistener() {         public void actionperformed(actionevent e)          {             if (checkbxwinrar.isselected())             {                 lblwinrarwirdjetzt.setvisible(true);                 program = '0';             }             else             {                 lblwinrarwirdjetzt.setvisible(false);             }         }     });     checkbxwinrar.setbounds(37, 398, 104, 18);     contentpane.add(checkbxwinrar);      jbutton btnnewbutton = new jbutton("install");     btnnewbutton.addactionlistener(new actionlistener() {         public void actionperformed(actionevent arg0)          {             if (checkbxopera.isselected())             {                 try                  {                     system.out.println(installableprograms[4].path);                     runtime rop = runtime.getruntime();                     process rt = rop.exec(installableprograms[5].path);                     rt.waitfor();                     joptionpane.showmessagedialog(null, "opera wurde erfolgreich installiert");                 }                  catch( ioexception | interruptedexception ex)                  {                     joptionpane.showmessagedialog(null, "ein fehler ist aufgetreten! möglicherweise " +                      "existiert die datei nicht, oder der eine pfad ist nicht korrekt");                 }             }         }      });     btnnewbutton.setbounds(414, 465, 147, 39);     contentpane.add(btnnewbutton);    }    private void url() throws interruptedexception, ioexception  {     file file;     try {            file = new file(urlexe.touri());            system.out.println(urlexe.getpath());         runtime rop = runtime.getruntime();         process rt = rop.exec(urlexe.getpath());         rt.waitfor();         } catch(urisyntaxexception|ioexception e) {            file = new file(urlexe.getpath());           system.out.println(urlexe.getpath());         runtime rop = runtime.getruntime();         process rt = rop.exec(urlexe.getpath());         rt.waitfor();         }       joptionpane.showmessagedialog(null, "opera wurde erfolgreich installiert"); } } 

can me?


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -