Is there some way to setup a GWT UpLoad to start browsing from a specific folder ?
To have the windows browser work from a specific folder ?
or is that impossible in which case you would have to use some other way...
Could JAVA WEB START as shown here be limited or start from a specific folder ?
http://docs.oracle.com/javase/tutorial/uiswing/examples/components/JWSFileChooserDemoProject/src/components/JWSFileChooserDemo.java
You won't be able to change the default directory for uploads in a browser from a web page. That's a security issue - see commentary control the working directory for <input type=“file”>?.
Given permission to the local machine, Java applets/applications deployed JWS would have the ability - additionally, ActiveX controls could also work for you if you're focusing on Windows.
Related
I've coded a game in Eclipse (still working on it), is it possible to run it's jar file in browser so that anyone can play right from their browsers instead of downloading jar file?
I.e I upload it on my website so that anyone can play right from the link I provide them.
Consider using Java Web Start with JNLP. You can host a JNLP file on a web server somewhere, along with your jar, and users can use a desktop shortcut pointing to the link, or a browser to open your app. (Using a browser will require having a web page with an applet tag: the article mentions how to do this but doesn't separate the two.)
I have a web application built on the JVM. In this application the users are able to upload files. I read the contents of the file and do "something" with it.
In addition to this, I would like to give option to the users to put in a directory path. This directory path will be read by the application and the directory will be scanned for all relevant files (.CSV). And each will be processed.
Questions
Will the web-application be able to scan the directory located on the users machine? Or the directory path need to be in a network to which the web-app has access to?
I will be using the Commons IO package to scan the directory for files and process the files, is there a better approach?
You cannot access file system of user machine from pure web application. This task can be implemented using trusted applet or java application executed via java web start or trusted flash component or other native component (browser plugin).
Applets are almost obsolete and require JVM on client side. Java web start still requires JVM. All signed components (java based, flash, native code) require user approval.
I think that better and more modern way is to use a great feature of HTML 5 that allows not navigation to specific location on disk (that was possible since HTML 1.0) but also selecting a full directory.
Take a look on the following discussion for details: Does HTML5 allow drag-drop upload of folders or a folder tree?
I have a set of help files for my SWT application that I have open in-application using the Browser control. Navigation through the help files is done through hyperlinks of relative pathnames (i.e: <a href="aboutUs.htm">, so only one html file is actually opened by java code, helpHome.htm. I am opening this using String homeURL = this.getClass().getResource("/help/helpHome.htm").toString(); and browser.setURL(homeURL); This works beautifully when I'm just debugging it in Eclipse. Unfortunately, when I move the project into a .jar, the browser gives the standard "can't find this webpage" error. I've tried using the browser.setText(String); function as described in this link, which works for helpHome.htm, but when I click a hyperlink, it brings me to a blank page displaying the relative pathname. Is there a way to convince browser to open an html file from an executable jar using the setURL(String) method? If not, are there any suggested workarounds for me to achieve similar results?
Thanks in advance!!
You have to start an internal Server as explained here on any available port on your application start up and make your html files available as static resources to the server.
Then set the browser.setURL(homeURL). All the subsequent hyperlinks will now point to the server, which knows how to serve the requested resources.
The hyperlinks are resolved to File System Path (Ex. file://C:\workspace....) while you are running or debugging your application in eclipse and things were working fine then. But that is not the case when you run your app from a runnable jar.
I have a need to "pop up" operating system folders from my web app, mostly to locate files in them. My users don’t want to use a conventional web upload/download paradigm. I have 7 or 8 static folders that need to be opened in explorer on a PC or in Finder on a mac. These folders are all network available, but are buried, and for convenience need to be shown on a web page.
There are IE tricks to do this, and I've written a sample flash app that only allows the browser to open, but I know most browsers sandbox this, and keep me from calling these folders. I am aware that some Java libraries deal with the opening of folders, does anyone have any thoughts or samples for this?
The only way I can imagine is to create a Signed Java Applet.
Applets cannot access the filesystem (and a lot of other ressources) if they are not valid signed. Maybe you can also grant the permission by a policyfile.
There ist a tutorial at JavaRanch.
But I am not sure, if this solution will be very helpful, because the JavaPlugin will be removed from a lott of browsers in near future. (I think FireFox already removed it).
I think there is actually NO solution to this problem.
There may be some workarrounds:
Put a Batch-File onto the server, which opens the folder, if executed
Can you create a local service, which handles requests from you webpage and opens the folder.
Create a webapplication, which opens the folder at serverside, and create a webpage, which displays the content in you website.
I have an application where javascript code is accessing java applet methods that write on local disk (just to note - this is not directly possibly, but there is a workaround for it that enables to do so). Applet is self-signed applet, so users have to allow it to run first.
If applet's codebase is set to "http://..." everything works fine, in FF, Chrome and Opera as well. However, I would like to put this applet on local file system. However, if I use codebase "file://..." (I also tried to not use codebase at all and write directly full jar path to archive) it does not work, applet does not load with Warning-Security pop-up that enable user to allow running the applets.
I only tested it in FF (3.6.1.4) so far, Java version is 1.6.0.21.
Are signed applets limited only for HTTP use? Or is there some workaround?
..is there some workaround?
Perhaps using the JNLP API services in an unsigned applet will work better. I have a demo. of the JNLP FileContents object.
For details on using the JNLP services in an embedded applet see the links to the 'next generation plug-in' in the applet information page.
Applets loaded from the local filesystem are allowed to write files only in, or below, the directory containing the applet. So, if the applet is in C:\MyProjects\MyAppletTest it will be able to read and write files in that directory and its subdirectories, but not in C:\MyProjects. You can override this behavior with a policy files as explained in Quick Tour of Controlling Applets