• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Application runs correctly in Eclipse but not as jar

 
Ranch Hand
Posts: 250
1
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following link will take you to the download page for the zipped project folder (via Dropbox).
https://www.dropbox.com/s/ev39aiplw1yteyy/Image%20Encryptor.zip?m

Basically, the program encrypts a message into the pixel information of an image. It can also decrypt encrypted images.

Once you get it running and see it working correctly in eclipse, you can export it as a runnable jar and watch it fail at file-writing and such.

Any help as to why this happens would be greatly appreciated.
 
Ranch Hand
Posts: 199
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Joel,

Could you attach a stack trace of the error?

 
Joel Christophel
Ranch Hand
Posts: 250
1
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I do this when running from a jar?
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Joel Christophel wrote:How do I do this when running from a jar?


Open terminal/command prompt.
Launch the jar using java -jar yourJarFileName
The terminal/command prompt will show you the stacktrace if any
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
did you checked your manifest file and mentioned main class ??
 
Joel Christophel
Ranch Hand
Posts: 250
1
Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Carles Gasques wrote:
Could you attach a stack trace of the error?



This is the line it messes up on only when run as jar:



Error:
java.io.FileNotFoundException: Key.txt (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.util.Scanner.<init>(Unknown Source)
at com.joelchristophel.Key.getKey(Key.java:19)
at com.joelchristophel.Key.<clinit>(Key.java:11)
at com.joelchristophel.Encryptor.<clinit>(Encryptor.java:18)
at com.joelchristophel.EncryptionPanel$3.doInBackground(EncryptionPanel.
java:229)
at com.joelchristophel.EncryptionPanel$3.doInBackground(EncryptionPanel.
java:1)
at javax.swing.SwingWorker$1.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at javax.swing.SwingWorker.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

EDIT: I solved the problem by instead using this line:
 
reply
    Bookmark Topic Watch Topic
  • New Topic