• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trouble loading resource in Linux build  RSS feed

 
chris seikatsu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the code in question.



I'm using this to load images from a JavaFX application. It works on Windows in Netbeans and the live distribution. It works on in Linux in Netbeans but it does not work in the live distribution. I've tried changing it to use Resource , ResourceAsStream , ClassLoader , etc. but none of those work either. The only way I've been able to get files to load in the Linux distribution is by loading them manually using the full path name. The OS in question is Linux Mint 18.2. To sum up the problem it works on the Windows build but not the Linux build.
 
Tim Cooke
Marshal
Posts: 3962
234
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
live distribution? What exactly is that?
 
chris seikatsu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Cooke wrote:live distribution? What exactly is that?


The final build. It works in Netbeans but not in the distribution build on Linux. The distribution build works fine on Windows.
 
Tim Cooke
Marshal
Posts: 3962
234
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. You say "loading them manually" work ok, which implies the failing scenario is some sort of automated process? Can you expand on that?
 
Dave Tolls
Ranch Foreman
Posts: 3010
37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, what is the filePath being used that is working on Windows and not on Linux?
And where do those files live?
 
chris seikatsu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:Also, what is the filePath being used that is working on Windows and not on Linux?
And where do those files live?


The files are coming from an asset folder. I've added the folder to the distribution build using an ANT script in the build file. Nothing changes between the versions. I ran one test using an absolute path in the final build and it that was the only way I could get it work on Linux Mint. Using resources , resrouceStream etc all failed. The final build works on Windows. I can only get it to work in the Netbeans IDE on Linux.
 
chris seikatsu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:Also, what is the filePath being used that is working on Windows and not on Linux?
And where do those files live?


My only guess is it's something to do with the characters Linux uses to find file paths.
 
Tim Cooke
Marshal
Posts: 3962
234
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without seeing this list of file paths it's hard to say what's wrong. Is it the same list you're using for Windows and Linux? Are you taking into consideration that Windows uses backslashes "\" for directory separation and Linux uses forward slashes "/"?
 
chris seikatsu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I finally got it working. My code is correct. I'm not logged in as root so the Jar doesn't have read and write permissions. I ran the Jar from the terminal using root permissions and it worked.

I'm not sure what is causing this Jar to need to root. I run other Jars that read and write with standard user permissions. At least I know how to get it working.
 
Tim Cooke
Marshal
Posts: 3962
234
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You also now know how to leave your machine wide open to getting hacked. Running your jar as root as a final "solution" is a terrible idea. Now that you know the problem is a file permission one, I recommend you implement a proper solution to run your application as a restricted user and give your application as much file access as it needs, and no more.

If you do decide to run your application as root, please post the URL to your application here, I could do with a new machine for mining BitCoin.
 
chris seikatsu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Cooke wrote:You also now know how to leave your machine wide open to getting hacked. Running your jar as root as a final "solution" is a terrible idea. Now that you know the problem is a file permission one, I recommend you implement a proper solution to run your application as a restricted user and give your application as much file access as it needs, and no more.

If you do decide to run your application as root, please post the URL to your application here, I could do with a new machine for mining BitCoin.


You must be a master hacker since you can break into my computer because I ran one application with no networking capabilities as root. You probably got my NIC card address and social security number just from reading this post. I bow down to your elite hacking skills. Please leave me alone mighty master hacker.
 
Campbell Ritchie
Marshal
Posts: 56223
171
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too late: Tim has posted your credit card details, SS number, blood group, and all your friends' phone numbers on https://www.hakkerzrool.com.zzz/victims/seikatsu%20chris.asp already.
Unsafe programming remains unsafe even when you are in a safe location like not being connected to any networks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!