I'm using code from here to change my desktop background to a set picture. This code works perfectly in Eclipse, but when I package the application to a runnable jar, it doesn't do anything. Running
java -jar DesktopChanger.jar
from the command line doesn't result in any errors. It just prints out a job completed message (sysout) and ends, but the wallpaper didn't change.
I imported the jna libraries jna-platform-4.1.0.jar
and jna-4.1.0.jar
from here. The only difference between my code and the other question is a sysout, a messageDialog
to say the job finished, and the location of the picture:
String path = "src/background/changer/picture.jpg";
Finally, in Eclipse I right click on the project
- hit "Export"
- select "Runnable JAR File"
- select "Package required libraries into generated JAR"
- and finish.
I've even messed with the Manifest.mf
file since Eclipse sets "Main-Class:" to it's own main, using "Rsrc-Main-Class" for the actual one. So I deleted "Rsrc-Main-Class" and put my main into "Main-Class" but again nothing works.
Do I also need to package the native code or dll files?