I wanted to work with the files, the program works in IntellijIdea, but when I create a .jar file it does not save the change to the file, it gives an error. Here is the code:
public void saveMarshall(Group currentGroup) { try { File file = new File(new URL(getClass().getResource("/resources/office_list.xml").toString()).getPath()); JAXBContext context = JAXBContext.newInstance(Group.class); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.marshal(currentGroup, file); } catch (JAXBException exception) { Logger.getLogger(Application.class.getName()). log(Level.SEVERE, "saveMarshall threw JAXBException", exception); } catch (MalformedURLException e) { e.printStackTrace(); } } Throws FileNotFoundException or this:
ΡΠ½Π² 27, 2017 1:10:26 AM com.google.javafx.objects.Application saveMarshall SEVERE: saveMarshall threw JAXBException javax.xml.bind.JAXBException - with linked exception: [java.io.FileNotFoundException: file:\D:\IdeaProject\JavaFXInstaBot\out\artifacts\JavaFX\JavaFXWorkXMLFile.jar!\resources\office_list.xml (Π‘ΠΈΠ½ΡΠ°ΠΊΡΠΈΡΠ΅ΡΠΊΠ°Ρ ΠΎΡΠΈΠ±ΠΊΠ° Π² ΠΈΠΌΠ΅Π½ΠΈ ΡΠ°ΠΉΠ»Π°, ΠΈΠΌΠ΅Π½ΠΈ ΠΏΠ°ΠΏΠΊΠΈ ΠΈΠ»ΠΈ ΠΌΠ΅ΡΠΊΠ΅ ΡΠΎΠΌΠ°)] at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:108) at com.google.javafx.objects.Application.saveMarshall(Application.java:94) 