• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can't get serializable to work in executable Jar? path problem?  RSS feed

 
Joen Ferreira
Greenhorn
Posts: 4
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys, it's my first post on this forum!

Basically I have a serializable on my current Java Project which works very well when compiling and running on Eclipse.
However when I put it into a runnable Jar It won't work at all. All files are included on the jar though (I have checked)

This is how the code to save/load file looks like:



I'd appreciate any help or suggestions!
 
Stephan van Hulst
Saloon Keeper
Posts: 7987
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So what's the exception?
 
Norm Radder
Rancher
Posts: 2240
28
 
Knute Snortum
Sheriff
Posts: 4279
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
However when I put it into a runnable Jar It won't work at all.

Could you be more specific about what happens? Do you get an error? If so, could you post the entire error?
 
Joen Ferreira
Greenhorn
Posts: 4
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I simply changed the path to "user.home" and it fixed the problem!
thank you for replying though, thank you guys!
 
Dave Tolls
Ranch Foreman
Posts: 3061
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The issue was (I expect) that the directory tree didn't exist when run from a jar (src/img), which did exist in Eclipse.
Of course, if Joen is just using user.home as the directory then the serializable stuff will be spammed into the user root, which is not all that tidy and might annoy some people.
 
Joen Ferreira
Greenhorn
Posts: 4
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:The issue was (I expect) that the directory tree didn't exist when run from a jar (src/img), which did exist in Eclipse.
Of course, if Joen is just using user.home as the directory then the serializable stuff will be spammed into the user root, which is not all that tidy and might annoy some people.


I have only started java a at the start of the year at uni, I'm really a beginner some stuff still doesn't make sense to me I'm sorry but I accept any criticism or suggestion I really appreciate any help specially because I have no idea of what it is to have a real job as a developer, I'm sure I still have a lot to learn before someone even tries to hire me after uni and that really scares me!
Thank you for all for replying and trying to help I really do appreciate, expect to see more questions from me >. < . thank you !
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!