Java security policy file question - java

Okay guys, I am trying to get the interpreter to use my .policy file for some JAAS stuff I am doing. When I try to enter the extra entry (ie. policy.url.3=file:/C:/Test/raypolicy
) in my Windows:java.home\lib\security\java.security
file, it refuses to save the new entry. I get a Save not successuful prompt telling me to make sure that the program is not open in somewhere else. Of course, it is not open somewhere else.
I know that it is a wrong setting somewhere on my computer as I am able to save to my java security file on my computer at work. I am running a Windows 7 on my personal computer and a windows xp at work. I have also already checked the file settings for the security file and I am set up as the administrator so I have authority to change the file, etc. Any and all thoughts are welcome.

Make sure you run the editor you use to edit the file (e.g. notepad) as Administrator -- otherwise the file permissions set on that directory will not allow you to modify the file.
Right click on notepad, select "Run as administrator" then load the file in notepad, edit it and save it and that should work.

One more option that worked for me was,
Copied the original file java.security to my desktop.
Changed the desktop version using notepad++ or any editor
Saved it.
And copied back this updated version to original file replacing the entire file.
Opened the file to confirm the changes
Deleted the desktop version.

Related

Java File Corrupted

Yesterday, i've Closed Eclipse & then Turned Off The Computer, Now it's appear that a Crash has occured, when i started Eclipse again, Project List was empty So i've imported the Projects Again,
Problem : a Java Files is now corrupted, the file size seem correct, i can Open the File but the File is filed with "NUL" when i open it with a Text Editor & is empty when i open it in Eclipse,
I've tried to use the History Features of eclipse but there is No Any Backup in the .History Folder, only empty folders,
Is there any way to recover this Damaged .Java File ?
Thanks
if you use SVN, or other version controls, or ever back up your PC, you could look at restoring it from there. However, by your description, this doesnt seem likely.
Noting from your comments you have tried a system restore.. System restore points and backing up your PC are two different things.
Right click on your file -> Properties.
The click "Previous Versions" along the top.
It may say "There are no previous versions available", or may offer a restore choice.
Perhaps if you had previously deployed the project you can get at the class file and de-compile the class back to code but that may still result in some loss. Also just try doing a search on your machine for that file name perhaps it was backed up by you at an earlier time that you forgot about.

How to make a .plist for a mac applications

I'm trying to turn a java program into a mac .app file, or more accurately, a native mac application. This requires a .plist file (see here) but I can't seem to find anywhere that works in telling me how to make one. I set up the directories as they specified, and my application debugs properly. Its just every time I try to open the application, it immediately shuts down. Does anyone know how to make a (minimalist even, for now) working plist file?
Right click on your project and select Export. Assuming you on using a Mac, there will be an option to output an application bundle.
Once you have created the app bundle (which itself is just a directory), go here to find the Info.plist file:
MyApp.app/Contents/Info.plist
From there you can edit the plist, if you need to.

Java store config and other files

Currently i am storing a few config files and a history.xml file right next to my executable .exe.
However some users have reported that they have to run my program with Administrator rights, otherwise settings and history is not saved to these files.
Where should i save my config files and history.xml in order to not require my users to run the app with administrator rights?
Would be really nice with a solution that works on both Windows and OSX
Any ideas?
Your users are probably saving the files in a folder under Program Files or another 'protected' folder.
Either they should save it in a users-folder, or you should work with a full path to some path on the system, like 'C:/myapp/'.
You can use a helper function to check if you're using Windows or *Nix, and then depending on that return a certain path. I'm not close to my computer so can't test but this should work:
return System.getProperty("os.name").egualsIgnoreCase("Windows");
You can also make use of "user.home" for the users home directory (always writeable) and "file.separator" so you don't even need to check whether you're on Windows or not.

reload java applet

i have a java applet in one html page, later, i modified the java code and regenerate the jar file. all i did is copy the jar file to my web server and brought up the browser to see the updated the appplet, but it still showed the old version. i tried refresh the browser, delete the cookies, still the same. i tried to open that html file by double clicking the file, it open it in browser with the right applet...i deployed the applet with jnlp. anyone knows what might go wrong? Thanks.
Go to the Java control panel and clear the Java caches*. The Java plugin does not use your browser for downloading Jar files.
*: Temporary internet files - configuration - delete files
Try this to clear the cache quickly without having to go through the tedious process of opening the Control Panel:
Open up the Java Console:
Windows:
http://www.java.com/en/download/help/javaconsole.xml
Use method 2.
Linux:
http://www.java.com/en/download/help/enable_console_linux.xml
And I can't insert a third hyperlink for Macintosh because I don't have enough reputation points yet......
Press 'x' to clear the cache!
I hope this works!
Jonathan's answer should do the trick, but in future I recommend you to load the applet from a new URL each time you update. For example http://www.domain.com/applet.jar?version=x

Can you determine if Vista UAC allows writing to a directory without elevation in java?

Here is the scenario. I have an application which writes a configuration file in its directory (user.dir). When the user cannot write to that directory due to UAC issues, I would like to change that to write to user.home/.appname/. The problem is that Windows really lies to my application and writes to user.dir which is in the Program Files directory, but although it allows the write and the read (even after restarts) it doesn't store it there, it stores it in a hidden directory (the home directory/AppData/Local/VirtualStore/Program Files/appname), making it hard/impossible for the user to find if they want to edit the file.
However, I don't want to just change my application to write to user.home and be done with it because some users run the application off of a USB drive, at which point I want to use user.dir if it is available, because it would not be helpful to leave things around the user home directory in that scenario (on a guest computer).
So after that rather long winded background, is there a way from java to know if the local directory is really truly directly writable from Java or if vista is going to instead virtualize the directory writes to another location?
This problem occurs if the Java executable is not marked as Vista compatible (using the manifest). The current release from Sun is marked as compatible. So the simplest solution is to use the latest release. This means that now neither files nor registry entries are virtualised.
Edit from author of OP:
Java 6 Update 10 (bug 6722527) added the manifest to the relevant files. Bug 6737858 addressed further issues, and is recorded as fixed in Release 12, although it is not in the release notes. For JDK 1.5, the installer was fixed in Update 11, however there will be no manifests added to the exe by Sun. You can add one yourself by putting the manifest file in the same directory as the exe if it is important enough.
After writing your file, can you just check that the file suddenly appeared in virtualized directory? I'd do a small "touch" file at app start to set a global boolean variable userUserHome.
Prepare a native EXE that loads the JVM in process (java.exe does this but you will need your own).
Add a manifest file (or in RC data) that specifies UAC as invoker.
Try writing to the folder to see if it works.
Or decide this is too much work and use a config file.

Categories