Hi
I'm having a problem with this code im creating a small application that just creates a txt file in my resource folder the problem is is I keep getting this exception
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
Now I dont get this exception if I change my code to this but I actually want to run this app as a standalone so this code wouldnt be effiencent help would be grateful
public void directoryFile() { path = Paths.get( "C:/Users/Genesis/Desktop/cv/My Applications/" + "Running Jar File Image Directory/Load Folders With Jar File 4/src/resources/jenny.txt" ); }
package loadFileWithJarFile; import java.io.IOException; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import javax.swing.JFrame; import javax.swing.SwingUtilities; public class LoadFileWithJar extends JFrame { /** * */ private static final long serialVersionUID = 1L; private Path path; public LoadFileWithJar() { // TODO Auto-generated constructor stub super(); setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); makeTextFile(); setSize( 500, 500 ); setVisible( true ); } public void directoryFile() { try { path = Paths.get( LoadFileWithJar.class.getResource( "/resources/jeny.txt" ).toURI() ); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void makeTextFile() { directoryFile(); try { Files.createFile( path ); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub SwingUtilities.invokeLater( new Runnable() { @Override public void run() { // TODO Auto-generated method stub new LoadFileWithJar(); } }); } }