在mac中按应用程序(.jar)读取/写入文件时,权限被拒绝

时间:2022-09-06 21:09:00

I have created an application in swing also created an installer for the same application.

我在swing中创建了一个应用程序,也为同一个应用程序创建了一个安装程序

both installer and the application run perfectly on windows system.

安装程序和应用程序在Windows系统上运行完美。

but my problem is when i try to run it in mac os it is not run perfectly with all data.

但我的问题是,当我尝试在mac os中运行它时,它不能与所有数据完美运行。

I have found that in my application i have used ".xyz" type property files and directory to save some data, so in mac os "." prepended serve as hidden file.

我发现在我的应用程序中我使用了“.xyz”类型的属性文件和目录来保存一些数据,所以在mac os中“。” pre pre用作隐藏文件。

it gives error like

它给出了错误

Error: /Users/userxyz/Library/Application Support/.appdir/.propertydir/.logininfo (Permission denied)

java.io.IOException: Permission denied
    at java.io.UnixFileSystem.createFileExclusively(Native Method)
    at java.io.File.createNewFile(File.java:883)

Is there any one who have solution to resolve above error?

有没有人有解决方案来解决上述错误?

1 个解决方案

#1


4  

The problem is in Mac OS.

问题出在Mac OS上。

No, the problem is not having permission to write to the Library directory of userxyz. Java WebStart is usually more than sufficient, but you should at least follow the approach recommended in Technical Q&A QA1170: Important Java Directories on Mac OS X. Note the distinction between user preferences, user data and application support, each of which is rooted in System.getProperty("user.home"). Note also that, java.util.Preferences uses ~/Library/Preferences/your.qualified.name by default. In addition, there's no reason to use hidden file names.

不,问题是没有权限写入userxyz的Library目录。 Java WebStart通常绰绰有余,但您至少应该遵循技术问答QA1170中推荐的方法:Mac OS X上的重要Java目录。请注意用户首选项,用户数据和应用程序支持之间的区别,每个用户首​​选项都植根于System .getProperty( “的user.home”)。另请注意,java.util.Preferences默认使用〜/ Library / Preferences / your.qualified.name。此外,没有理由使用隐藏文件名。

#1


4  

The problem is in Mac OS.

问题出在Mac OS上。

No, the problem is not having permission to write to the Library directory of userxyz. Java WebStart is usually more than sufficient, but you should at least follow the approach recommended in Technical Q&A QA1170: Important Java Directories on Mac OS X. Note the distinction between user preferences, user data and application support, each of which is rooted in System.getProperty("user.home"). Note also that, java.util.Preferences uses ~/Library/Preferences/your.qualified.name by default. In addition, there's no reason to use hidden file names.

不,问题是没有权限写入userxyz的Library目录。 Java WebStart通常绰绰有余,但您至少应该遵循技术问答QA1170中推荐的方法:Mac OS X上的重要Java目录。请注意用户首选项,用户数据和应用程序支持之间的区别,每个用户首​​选项都植根于System .getProperty( “的user.home”)。另请注意,java.util.Preferences默认使用〜/ Library / Preferences / your.qualified.name。此外,没有理由使用隐藏文件名。