Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

security restrictions of file I/O?  RSS feed

 
Joe McIntyre
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Making a java desktop app that will be deployed in a jar file to multiple operating systems. I want to write a file to disk so that after the user shuts the app down and then later fires it back up again I can then read the file back in from the disk. Seems like this was troublesome years ago because the security api required certain settings in order to give the app access to the disk. I'm just asking a general question because I won't be able to do extensive testing on various hardware and op systems - is it still the case? that security can get in the way of file I/O? Do I need to be concerned about this?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This sounds a bit odd, because desktop apps generally are not run with a security manager (which might prevent file I/O). So unless there are specific circumstances in your case, the app should have no problems.

An alternative to storing data between app invocations might be to use the java.util.prefs package, although it might not be appropriate if the amount of data is large.
 
Joe McIntyre
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankee Sheriff! Interesting reply... is writing to the registry a reliable way of copy protecting a java desktop app? Say for example, your app will only write to the registry just after it has gotten permission from the server. Then it writes an entry indicating that the software has been legitimately purchased and registered. Now if installed onto another machine or if the jar file is copied onto another machine, the app starts up, sees there's no registry entry and so assumes it's a new installation... but when it contacts the server asking for permission to write to the registry, the server doesn't give permission because it knows from the database that the software has already been installed.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a pretty reliable method from the software producer's point of view. It's not so reliable for the user who has a legitimate reason for moving the application to a new computer or to the same computer after a major cleanup.
 
Joe McIntyre
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul. I think I figured out an easy way to permit legitimate reinstallations. But I have one other question - would this work on a Mac too, or would I have to have one version of the software for mac and another for windows?
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you abstract from "write to the registry" to a platform-independent idea, you come to Java's Preferences API which -- of course -- is available on all platforms.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!