Disable IO in java app (not java -D)

I don't want any program to be allowed anything more than a standard applet except when it is specified in a policy.
The code (posted below) listens to my policy file when run as an applet but ignores the java.security and java.policy when started with java.
The command "java test" gives me no exceptions at all, the default (I guess) is to allowe java apps to do what they want.
So my question is can I set the security or policy so it won't allowe anything unless specified in a policy file?
import java.util.Properties;
import java.applet.Applet;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class test extends Applet implements Runnable {
            public test(){
                new Thread(this).start();
         public static void main(String argv1[]) {
              new test();
            public void run(){
                 try{
                      System.out.println("java.home is: " + System.getProperty("java.home"));
                      System.out.println("user.home is: " + System.getProperty("user.home"));
                          File fle = new File(System.getProperty("user.home") + System.getProperty("file.separator") + "sometext.txt");
                             FileOutputStream outFile = new FileOutputStream(fle);
               outFile.write("hello, this is written by Java".getBytes());
               outFile.close();
                          FileInputStream inFile = new FileInputStream(fle);
                          int b = inFile.read();
                  while(b!=-1){
                               System.out.print((char) b);
                               b = inFile.read();
                      inFile.close();
                 }catch(Exception e){
                      e.printStackTrace();
// java.security:
security.provider.1=sun.security.provider.Sun
security.provider.2=com.sun.net.ssl.internal.ssl.Provider
security.provider.3=com.sun.rsajca.Provider
security.provider.4=com.sun.crypto.provider.SunJCE
security.provider.5=sun.security.jgss.SunProvider
securerandom.source=file:/dev/random
login.configuration.provider=com.sun.security.auth.login.ConfigFile
policy.provider=sun.security.provider.PolicyFile
policy.url.1=file:${java.home}/lib/security/java.policy
# the following line gives me an opportunity to give special prifs to programms and applets
# policy.url.2=file:${java.home}/lib/security/localApplet.policy
# don't want to allowe the user to change policy
# policy.allowSystemProperty=true
policy.expandProperties=true
policy.ignoreIdentityScope=false
keystore.type=jks
system.scope=sun.security.provider.IdentityDatabase
package.access=sun.
ssl.KeyManagerFactory.algorithm=SunX509
ssl.TrustManagerFactory.algorithm=SunX509
networkaddress.cache.negative.ttl=10
java.policy:
// you guessed correct thisone is empty

Thanx for taking the time to respond.
Sorry, I see my pref post was wrong. The code is OK but the java.policy looks loke this:
// Standard extensions get all permissions by default
//grant codeBase "file:${java.home}/lib/ext/*" {
//     permission java.security.AllPermission;
// default permissions granted to all domains
grant {
     permission java.lang.RuntimePermission "usePolicy";
};The usePolicy means that applets allways use policy to see what permissions they have.
Compiled test.class and made a html file containter:
<applet code="test.class" width="100" height="100"></applet>
When I run: appletviewer test.htm
Sure enough I get a security exception:
java.security.AccessControlException: access denied (java.util.PropertyPermission java.home read)
when I run the same code like this:
java test.class there is no exception at all, I was wondering how can I force all classes to use policy?
I think you can set your applications security manager to anything you
want.
If you can work out the Applets security manager class, you should be
able to instantiate it and set it for your application.I didn't work out the Applets security manager if you are referring to: security.provider.1=sun.security.provider.Sun in the java.security.
I just configured the policy.
Sorry for the wrong info in my pref post that might have you thinking I rewrote/subclassed the security provider.
http://java.sun.com/docs/books/tutorial/security1.2/tour2/step2.html
Tells me how to use -D but there is nothing on allways forcing policy on any class.

Similar Messages

  • Java apps not working right

    I lately have found problems with Java apps not working correctly. For example, in Yahoo Widgets I cannot get any widget preferences to display; in Apple's Java Preferences for J2SE 5.0 the preference window opens but is blank; and in JBidwatcher the buttons are missing in main and preference windows.
    When I log in as another user I find all those apps work properly, so it seems to be something wrong within my User folder. I tried reinstalling the Java J2SE50ReIease4 but it didn't help. Is there something I can delete and/or reinstall to fix this problem?

    Ditto here,
    I made the mistake of thinking I could throw away the preferences in the Java folder and new pref's would automatically replace the missing pref's, much to my surprise no such thing happened. My settup is the same as yours, except my OS is 10.4.8.
    Someone please help.
    Thanks,
    BJZTX
    G5 D2GHz   Mac OS X (10.4.7)   G4 Notebook 10.3

  • Opening a file from a java app (not applet)

    My program can't find the text file I'm trying to open in my stand-alone java app. I am specifying it like this:
    File filename = new File("myfile.txt");
    FileReader = new FileReader(filename);
    It is in the same directly as the class files. It won't find it when it's in a jar file either. I had a similar problem with an applet a lont time ago, but that turned out to be a security issue, which I assume normal apps don't have.
    So, what's up with this?

    If system become larger, there are duplicated files
    can be found in different directories.
    Using classpath may cause problem, if there are
    duplicated file name.
    If you are coding, you should know exact location of
    the file to be opened.
    "system become larger" - huh? You control the classpath on a per-app basis, not one huge monolithic classpath containing all jars/folders for all apps.
    It's common, well-designed practice to use the classpath. It's bad practice to hard-code directory names and expect all deployments of the app to follow the same directory naming convention. I wouldn't want you to dictate to me where to put the file on my hard drive. I should be able to install it anywhere I want, and let it find it (via the classpath, in this instance).

  • Java apps not displaying correctly

    Hi.
    I'm having a problem with Java apps, as they seem to simply not display correctly. They are supposed to be Aqua, but it doesn't exactly work, since the actual controls don't appear, but besides that the program seems to carry out what it's supposed to (besides not displaying it correctly.)
    I tried removing some Java-related setting files and stuff, but it still doesn't exactly work as it should.

    The problem isn't with the Window Manager you use, but the java runtime you have installed. If you have openjdk6 installed, try removing it and install jre and jdk instead. If you have jre and jdk installed, install openjdk6 and see what happens.
    I think you're using openjdk6, since I remember hearing problems using it and topcoder.
    Last edited by CursedMonkey (2009-05-21 19:11:54)

  • Java app not working

    I have a MacBook Pro laptop and after I followed your advice I constantly get a message that reads, "Alert! This update requires Mac OS X version 10.6. My latest version is 10.8.2. It is too late for me to phone AppleCare. Community, please help with this problem.
    Thank you,
    Marlin

    I'm not sure exactly what you're trying to do or what advice you're following. It sounds like you are trying to install a Java update for Mac OS X 10.6, which you can't do because you're not using 10.6.
    Are you trying to upgrade Java or downgrade Java or what? What app is not working? What problem are you trying to solve?

  • Running Java app when java not installed

    I need to run java apps on a server I don't control and the admin will not install java. :(
    Tried a few things to run java without installation, but get error that a java registry item can not be found. "Error opening registry key 'Software\JavaSoft\Java Runtime Environment'" Might be that without control of the registry, there's no way to run the java engine, but curious if there's a way to get it to run... I'm gonna play around with it, but figured if someone out there knows it's not possible, they could save me time by letting me know.
    Thanks!

    Depends on what you want to run. To run an applet on the computer requires that the JRE be installed, as the applet needs the Java Plug-in and Registry keys that the JRE install includes. To run a Java program from the command line needs a copy of the JRE, but it does not need to be "installed" by the Java installer. Then the command "java ... classname" needs to include the full path to the java executable that the JRE contains.
    There might be websites that allow you to run certain kinds of Java programs on the website. I don't know if they still wxist. I also doubt that they'll run applets.

  • Java app not running in linux

    I developed an application in windows and ran successfully. The same i ran in linux and getting the follwing error.
    Please help.
    Thanks
    [root@uma apple]# java -jar apple2.jar
    Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/java/j2sdk1.4.2_10/jre/lib/i386/libawt.so: libXp.so.6: cannot open shared object file: No such file or directory
            at java.lang.ClassLoader$NativeLibrary.load(Native Method)
            at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1586)
            at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1503)
            at java.lang.Runtime.loadLibrary0(Runtime.java:788)
            at java.lang.System.loadLibrary(System.java:834)
            at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
            at java.security.AccessController.doPrivileged(Native Method)
            at sun.awt.NativeLibLoader.loadLibraries(NativeLibLoader.java:38)
            at sun.awt.DebugHelper.<clinit>(DebugHelper.java:29)
            at java.awt.Component.<clinit>(Component.java:506)
            at apple2.main(apple2.java:628)
    [root@uma apple]#

    It's probably not happening because you missed the -c from the su command. However this isn't the correct approach to daemon processes on linux (which is what you're after).
    What you need to do is to place a script in the /etc/init.d directory. This script should take a single argument and start the daemon if the argument is "start", and stop it if "stop". Check out the scripts already in there to see how it's done.
    Then go to System Settings/Server settings/Services and enable the new service for the normal run level.

  • N6131 - java app problem - java.io.IOException

    Hi,
    I need to help with the following problem - I convert e-books from TXT to the phone (my mother's 6131) using free soft Readmaniac that can take a TXT file and a font file and create a Java application. Unfortunately, my mother recently has following problem (I checked it and it is sure) - she cannot even open one book and th device always says:
     java.io.IOException:
    No free space to create file BOOK.IDX: .... error
    although the java app file si located on a 2GB microSD card - the phone sees it without problem and there is there more than 90% free on the card. Deleting a few books does not help. For some time - about the first twenty books, it worked fine, but in recent times this is the third time it crashed. Other applications - Dictionary Kodi, Frozen Bubble (microFB), etc. are going to continue to run without a problem.
    There always arise files with 'crash' in the title, suffix RMS, deleting them helps for a short time. Does anybody know, where could be problem? I used readmaniac for a long time my phone (SE K300i) and never had problems.
    thanks for any tips
    PS: the phone was bought in local Vodafone store (I think it has slightly customized software), but currently there is O2 sim card.

    *"but i have had a couple spontaneous system shut downs where the screen has just gone black and i have had to do full restarts since the upgrade also so wondering if something got misrouted when that happened."*
    *You didn't once make any reference to system glitches*. What you need to do at this point is get your install disk and check the boot disk for errors.
    Restart your Mac while holding down the C key, pressing the power button and inserting your install disk all at the same time. An Installer window will open, but do not proceed with any installations. Instead, from the Menu Bar, select Utilities/Disk Utility. In the Disk Utility window click First Aid, and then click Verify. If Disk Utility reports errors, click Repair. When Disk Utility is finished, from the Menu Bar, select Utilities/Startup Disk. Select MacintoshHD 10.x.x and click Restart.
    If you do not feel confident enough to do maintenance on your iMac, then you need to take it in for repairs.
    Carolyn

  • Java Apps not working

    I just get that coffee cup symbol endlessly on java pages. Any quick fix?

    From the Downloads tab above. I'd try the J2SE 5.0 Release 4 and select Intel or PPC whichever is appropriate. You might have to delete the Java.pkg or other Java-related .pkg files in Receipts before you can install it.

  • Using a regular JAVA class (not java bean)

    I have a regular class which I have created & I want to use in a JSP Page.
    How can I import it?

    Put a JSP import on the top of your page
    <%@ page import="yourclassname" %>
    Post JSP questions in this forum
    http://forum.java.sun.com/forum.jsp?forum=45
    Thanks

  • 5800XM need keyboard to enter data in java app

    I have downloaded an app to my 5800 but once in the app i need to enter my account details.
    There is no keyboard in the app to allow me to enter the details.
    any ideas please
    Pat

    No idea's yet, but same issue.  I get a D-Pad in my Java apps (not a number pad) and I have a few apps where clicking th custom edit box doesn't give you a choice to bring up a keyboard (the Opera Mini app - address bar is an example.  filed a bug with Opera against that)

  • Problem with Java app on Mac OS X... works fine in PPC, not on Intel

    Hi all,
    I'm at a loss... I've always been under the impression that java is the same no matter where it's running, but I've come across something that surely counters that line of thought. At work, we use a java application from DTI to publish our newspaper. This app works just fine on Mac OS X 10.4.x on PPC Macs, but the same application doesn't work on Intel Macs, also 10.4.x.
    The app launches and appears to be working fine, but there's a point where it must download some support files from the server. This is where it breaks with the error:
    java.io.IOException: null, com.dtint.macutils.AppFile.decode
    The corresponding entries in the console log show this:
    java.io.IOException: null,com.dtint.macutils.AppFile.decode
         at com.dtint.macutils.Codec.invoke(Codec.java:96)
         at com.dtint.macutils.Codec.decode(Codec.java:112)
         at com.dtint.install.InstallFile.decode(InstallFile.java:218)
         at com.dtint.install.Download.db2File(Download.java:277)
         at com.dtint.install.Download.run(Download.java:143)
    Caused by: java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.dtint.macutils.Codec.invoke(Codec.java:91)
         ... 4 more
    Caused by: java.io.IOException
         at com.dtint.macutils.AppFile.decode(AppFile.java:130)
         ... 9 more
    Caused by: java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.dtint.macutils.AppFile.decode(AppFile.java:125)
         ... 9 more
    Caused by: java.io.FileNotFoundException: /Volumes/ChopAdSizeMove.scpt.encoded (No such file or directory)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(FileInputStream.java:106)
         at java.io.FileInputStream.<init>(FileInputStream.java:66)
         at glguerin.macbinary.MBFileDecoder.decodeFile(MBFileDecoder.java)
         at com.dtint.macutils.MacFileIO.decode(MacFileIO.java:163)
         at com.dtint.macutils.AppFile_60.decode(AppFile_60.java:94)
         ... 14 more
    File Download Time (ms) = 12428
    If there are any other logs I can provide, let me know what would be helpful and I'll get them.
    I've got no clue why this wouldn't work across platforms unless it was compiled for the PPC processor or something, but then wouldn't it either launch in Rosetta or not at all on the Intel? I'm a systems admin, not a programmer, so I've really no idea where to start looking.
    What I have done to this point is made sure I'm on the latest Apple-released Java, as well as copied the Java files from the PPC to the Intel to see if there was something there. Nothing makes any difference.
    This would be a major coup if I could get this working... does anyone have any thoughts or ideas about getting this to work?
    Many thanks in advance!
    Jason

    Hi all,
    I'm at a loss... I've always been under the impression that java is the same no matter where it's running, but I've come across something that surely counters that line of thought. At work, we use a java application from DTI to publish our newspaper. This app works just fine on Mac OS X 10.4.x on PPC Macs, but the same application doesn't work on Intel Macs, also 10.4.x.
    The app launches and appears to be working fine, but there's a point where it must download some support files from the server. This is where it breaks with the error:
    java.io.IOException: null, com.dtint.macutils.AppFile.decode
    The corresponding entries in the console log show this:
    java.io.IOException: null,com.dtint.macutils.AppFile.decode
         at com.dtint.macutils.Codec.invoke(Codec.java:96)
         at com.dtint.macutils.Codec.decode(Codec.java:112)
         at com.dtint.install.InstallFile.decode(InstallFile.java:218)
         at com.dtint.install.Download.db2File(Download.java:277)
         at com.dtint.install.Download.run(Download.java:143)
    Caused by: java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.dtint.macutils.Codec.invoke(Codec.java:91)
         ... 4 more
    Caused by: java.io.IOException
         at com.dtint.macutils.AppFile.decode(AppFile.java:130)
         ... 9 more
    Caused by: java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.dtint.macutils.AppFile.decode(AppFile.java:125)
         ... 9 more
    Caused by: java.io.FileNotFoundException: /Volumes/ChopAdSizeMove.scpt.encoded (No such file or directory)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(FileInputStream.java:106)
         at java.io.FileInputStream.<init>(FileInputStream.java:66)
         at glguerin.macbinary.MBFileDecoder.decodeFile(MBFileDecoder.java)
         at com.dtint.macutils.MacFileIO.decode(MacFileIO.java:163)
         at com.dtint.macutils.AppFile_60.decode(AppFile_60.java:94)
         ... 14 more
    File Download Time (ms) = 12428
    If there are any other logs I can provide, let me know what would be helpful and I'll get them.
    I've got no clue why this wouldn't work across platforms unless it was compiled for the PPC processor or something, but then wouldn't it either launch in Rosetta or not at all on the Intel? I'm a systems admin, not a programmer, so I've really no idea where to start looking.
    What I have done to this point is made sure I'm on the latest Apple-released Java, as well as copied the Java files from the PPC to the Intel to see if there was something there. Nothing makes any difference.
    This would be a major coup if I could get this working... does anyone have any thoughts or ideas about getting this to work?
    Many thanks in advance!
    Jason

  • Java GUI apps not working

    All my Java apps are not rendering their GUI properly anymore. It seems to affect those that are using a Carbon-ized UI. I'm guessing this means all Swing apps?
    Regardless I'm trying to figure out a way to fix this without re-installing the OS...
    Any tips?
    thanks in advance.
    -j

    Have you tried deleting the Java caches? Close all your Java applications first. You'll find some in <user>:Library:Caches:Java Applets. While you're there you can also clean up anything else in the Caches folder that might be related - it's not a problem to remove anything in here, they'll just get recreated and may cause the related application to start up a bit slower next time.
    There should also be one or more 'Plugin Settings' files in the Applications:Utilities:Java (note: I'm on 10.3.9 and this may be different for you - I have two: one for 1.3.1 and one for 1.4.2). Launch them and use whatever features they have for cleaning up unwanted caches/mess, but I think they just remove the cache files I mentioned in the first paragraph.

  • Why is there a java enable function in the settings app if java ia not supported by ipad2?

    Why is there a java enable function in the settings app of the ipad2, ios5, when java is not supported by ios5 on the ipad2?  The adds say that java neo, I think that is what it is supposed to be called, was supposedly introduced into the ios5 format to deal with this?

    If you're looking in the settings for Safari, that's JavaScript, which despite the similarity in names is completely different from Java. Java is not, never has been, and all indications are never will be supported in iOS. I have no idea what "java neo" might be, but I've never seen Java mentioned in any way in any of Apple's iPad ads.
    Regards.

  • Whether java component (Not ejb, not servlet) can be deployed in App Server and get the services provided by App Server

    As I mentioned in subject, I am just wondering Whether the java component (Not
    ejb, not servlet) can be deployed in App Server and get the services provided
    by App Server or not?

    Nevermind folks - I got it to work. All my configuration was correct; I had other issues with the ejb-jar file that the verifier informed me of (my previous deployments were with the verifier turned-off).

Maybe you are looking for

  • OS X 10.3 Boot Problems

    I have an iMac G3 333 - tray load. I've got 256mb of ram in it and I just received a set of 10.3 installation disks - the black label ones - 4 in the set. My firmware is also at least v3.0, if not 3.0.1 or something like that. The original HDD was 6g

  • HT1212 ipod touch disabled due to too many incorrect password attempts - problem is I know the password

    My daughter's ipod touch is locked due to too many incorrect password attempts (thanks to her little brother).  It is displaying the red bar that states ipod is disabled connect to itunes.  Problem is we don't have the computer that the ipod was orig

  • New to Mac and considering a macbook?

    Hey Ya'll, I am posting a question because I am in need of help. I am new to Mac except for the iPods, and I am just scared to take the plunge. I am have been talking to people online about whether to go with a macbook or another PC, and have receive

  • After Efects Error: overflow converting ratio denominators.(17 :;18)

    Hello, I am experiencing a serious problem with after effects. It started when I right clicked a clip in my premiere pro timeline and chose "replace with after effects composition."  Upon moving the clip into my already open after effects project, th

  • What are all these unwanted sounds?

    Recently, after I've signed onto the my A8 17-inch laptop, the appearance of my desktop is accompanied by an obnoxious trumpet fanfare.  I have no idea why this started;  I sure did not program it.  The other day an annoying electronic sound accompan