Reputation: 197
Im trying to run my project jar from terminal. My project containing SWT library and image folder for the menu. I wrote on sh file the comman but im getting an error.
My script:
java -cp /root/Desktop/applicationFramework/SWT/swtLinux.jar:/root/Desktop/applicationFramework/images/AppMenu.png:/root/Desktop/mainProject.jar boot.Run
and the error im getting:
Exception in thread "main" org.eclipse.swt.SWTException: i/o error (java.io.FileNotFoundException: images/AppMenu.png (No such file or directory))
at org.eclipse.swt.SWT.error(SWT.java:4441)
at org.eclipse.swt.SWT.error(SWT.java:4356)
at org.eclipse.swt.graphics.ImageLoader.load(ImageLoader.java:176)
at org.eclipse.swt.graphics.ImageDataLoader.load(ImageDataLoader.java:26)
at org.eclipse.swt.graphics.ImageData.<init>(ImageData.java:377)
at org.eclipse.swt.graphics.Image.<init>(Image.java:668)
at view.MenuWindow.initWidgets(MenuWindow.java:52)
at view.BasicWindow.run(BasicWindow.java:52)
at view.MenuWindow.start(MenuWindow.java:211)
at boot.Run.main(Run.java:13)
Caused by: java.io.FileNotFoundException: images/AppMenu.png (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at java.io.FileInputStream.<init>(FileInputStream.java:101)
at org.eclipse.swt.internal.Compatibility.newFileInputStream(Compatibility.java:183)
at org.eclipse.swt.graphics.ImageLoader.load(ImageLoader.java:173)
... 7 more
what is the correct way to write the script to run my project?
Thank you.
Upvotes: 2
Views: 652
Reputation: 3676
There doesn't seem to be anything wrong with running the jar like this. But it is failing to find the resources it needs. My understanding is that it is looking for the image from the relative file path, not the class path, try copying the image it is loading images/appMenu. png to the relative directory you are running this from. Or run inside the original app bundle context such that the path will be correct, rather than from the desktop. Moving is preferred because there could be other resources loaded at runtime that are missing.
cd /root/Desktop/applicationFramework
java -cp SWT/swtLinux.png:/root/Desktop/mainProject.jar boot.Run
Upvotes: 1