java - How to make jar files that draw from a source folder -


i've been wanting make executable jar files java lately. when executing code eclipse works perfectly. when use eclipse export same code runnable jar, of jars work except ones draw separate source folders.

the jar made when launched try , open , check console possible errors. try , run jar through console command "java -jar test.jar". , says cannot access jar. ideas? btw im on macbook pro osx. thank you!! picture of files within eclipse

if have file want store in jar , access there, don't have java file more. @ class.getresourceasstream() , class.getresource() - first can give inputstream (used-to-be) file, second returns url , can used things images. note file being accessed can accessed relative package/folder location of class or relative classpath root (by putting "/" @ front of resource name ("/resource/funny.jpg")).

when execute jar command line, aware have thing called "default directory"; folder in commands execute default. if jar not in default directory, have specify valid folder path jar execute it.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -