nothing shown in java applet html file chooser - java

When I use java applet to create a open file button, it can show a file chooser for me to choose the file, but when i access to the applet html page generated by netbean, a file chooser is shown after I clicked the open file button, but no directory is shown and I cannot select the file. What can I do to solve this problem?

Related

Is there a way to convert a .xlsx file to a .xls file and a .docx file to a .doc file upon clicking a button in java?

I'm working on a java based web application. Which shows list of uploaded files by the logged in user along with hyperlink of the file and delete button. The delete button deletes the file from the database. Clicking on the hyperlink open the file content on the screen with suitable software. But users are not able to open files with following extensions: .xlsx and .docx. So I'm trying to convert the .xlsx file by copying the content to a new .xls file and copying the content of .docx file to a new .doc file and then show those files on screen.
I'm using richfaces with ajax.
<a4j:commandLink id="lnk_view"
action ="#{FileUploadController.view}"
style="display: none"
onclick ="startLoad();"
reRender="info"
oncomplete = "stopLoad();">
<f:param name="selectedFile" value="#{file.serialNo}"/>
</a4j:commandLink>
Expected Result: Clicking on the hyperlink/view button should show the content of the file selected on the screen.
Actual result: "workbook cannot be opened or repaired by microsoft excel because it is corrupted". However, the file is not actually corrupted, because we can open the file from the location it is saved.

Can't automatically choose file on <input type="file"> by using Selenium Webdriver

I ran webdriver, everything was great, until OS file browser pop-ups and webdriver can't interact with it so it can't automatically choose the file on file browser.
So how can I choose the file on file browser automatically?
Did you click an upload button?
Instead you'll want to find the input element with the type 'file'. Once you've located this, perform a send keys command with the file location.
E.g.
driver.findElement(By.xpath("//input[#type='file']")).sendKeys("File Location") ;

Java Desktop opens files with different extensions

I am using Desktop class to open files like .txt files, .pdf files, images, etc; I have a problem that when I open first file, lets say a .jpg file, the images are displayed in the image viewer, then I try to open a .pdf document, the Desktop object tries to open the .pdf file with the image viewer, and it fails.
When I open the .pdf file first, it opens correctly. After that when I try to open a .jpg file, it is opened in the pdf browser. And so it fails...
In short, the first program associated with the first file, is used to open all the other files.
how can I solve it ?

Opening a file from filechooser with a file's programm in Java

I want to open a file from filechooser with a file's extension. For exapmle, if a user select the file text.doc, then the word must open this file
Desktop.getDesktop().open(File file)
This will open the file with the default program if there is a default program. If IOException occured then there is no associated application or the associated application fails to be launched.

Dropdown Menu Opening Bat File

I need some help.I have a Java program with a drop-down menu,there is an option in that menu to launch a test.bat file, what code would I use to specify the system path for it to open test.bat? Test.bat is an external file for testing purposes.
EDIT
This problem has been resolved.
File f = new File("test.bat");
Desktop.getDesktop().open(f);

Categories