views:

411

answers:

4

I come from a C/C++ background and now do a lot of C# stuff.

Lately I have become interested in doing some projects in Java since playing around with the Android SDK.

I know that Java apps run in a sandbox that can limit their access to the system.

In a desktop/server application environment what kind of things are restricted?

+4  A: 

Typically desktop and server application run with security disabled. However, Java and the JVM still have a robust type system, so you can't for instance cast to types that an object was not created with, cannot access freed memory and can't run off the end of buffers.

Tom Hawtin - tackline
+9  A: 

Java applications are much in a sandbox as .NET applications are in a sandbox. They both run on their respective virtual machines, and do have some limitations as to what they can do, but for the most part, they have a good deal of access to the system, including access to native code through certain calls.

You may be thinking about Java applets, which run inside a browser, and generally will be in a security sandbox that prevents access to the system resources such as local files. (This restriction can be circumvented by specifically granting access to the system to certain applets.)

Here's a section on Security Restrictions for applets from The Java Tutorials, which includes a list of restrictions placed on applets.

coobird
A: 

I think the main limitation you might see, is the ability to easily use the native system API's if you needed, for example if you needed to use a user32 or kernel32 API from java I think it is possible, however it is not an easy task to do, however in C# it is fairly easy thing to do.

Also if you have some legacy C/C++ dll's you can still use them in a C# application, while in java is still hard to do especially that in the worst case when your native code api has to use pointers, you can use unsafe mode in C# application to pass pointers and allocate fixed memory on stack ... etc.

but as mentioned above Java & C# in general are very much have the same limitations especially if you are targetting being platfrom independent.

bashmohandes
+2  A: 

For normal desktop and server apps, the limitations are not related to the sandbox concept (though you could use it to apply very fine-grained restrictions to e.g. user-submitted code) but to the platform-independant nature of Java. Basically, OS-specific stuff and hardware access usually can't be done in pure JAVA unless specifically adressed by the API library.

Examples are:

  • Windows registry
  • Windows system tray
  • Bluetooth
  • WLAN configuration
Michael Borgwardt
Just to nitpick, in Java 6 you can actually access the system tray: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/systemtray/ But your basic point stands.
sleske