*
The moose likes JNLP and Web Start and the fly likes FileOpenService intialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JNLP and Web Start
Bookmark "FileOpenService intialization" Watch "FileOpenService intialization" New topic
Author

FileOpenService intialization

Mohamad Samy
Ranch Hand

Joined: Apr 26, 2013
Posts: 98
I just have started applets and I have a silly question. I know that the applet use the jnlp.jar in the jdk to retrieve data or save data in the file system. one of those services is FileOpenService which is initiated by the following code

why it is just initiated by like any object
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41107
    
  45
javax.jnlp.FileOpenService is an interface - you can't instantiate it directly.


Ping & DNS - my free Android networking tools app
Mohamad Samy
Ranch Hand

Joined: Apr 26, 2013
Posts: 98
ok, I agree. but how the lookup method instantiate a reference to object of it and cast it back to File Open Service.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41107
    
  45
By instantiating some class that implements the interface. You can find out which class that is on your particular JVM by printing out "fos.getClass().getName()". That likely won't do you much good, though, as it'll be an internal class of the JRE, and what's more, it'll be different on different OSes, so your code can't make assumptions what it's going to be.
Mohamad Samy
Ranch Hand

Joined: Apr 26, 2013
Posts: 98
I got you. You mean that JVM instantiate a class that implements this interface and the look up method bring the bject of this class. And because this new class not known to public it is casted to the type i want. Is that what you mean
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41107
    
  45
Sort of - the cast is needed because ServiceManager can look up services of various kinds, so the object type it returns depends on the service name being passed in. See http://docs.oracle.com/javase/7/docs/technotes/guides/javaws/developersguide/examples.html for some examples of other services.
Mohamad Samy
Ranch Hand

Joined: Apr 26, 2013
Posts: 98
Thank you for your quick response. I got it and i will read the link you put .
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: FileOpenService intialization
 
Similar Threads
How include jnlp.jar in Web project war file?
Get path from a FileContents instance
iam hetting error when compile a File open service
Update applet text runtime
my applet not working