Opening files from java application by other programs
Hi! Could you tell me how to solve such task. After saving of file on local drive by applet i need to show a link "View file" that will open file by assotiated programs (.doc - MSWord, .pdf - Acrobat Reader etc. applet will work on Linux platform too). Thanks!
Just provide a link to the file and leave it up to the OS to determine which program to use to open it.
Similar Messages
-
Running exe files from java applications
Hello All,
Is it possible to run executable files from java applications?
I need to run an exe file on the client from the server machine, the exe could reside on either the server or any other machine on the LAN. Is it possible to specify the path of where the exe resides, and run it on a client machine?HI,
I tried to launch a MS Word application using runtime.exec but it gives me some problem
The foll. code to launch a txt file using notepad works.
Runtime rt = Runtime.getRuntime();
String[] callAndArgs = {"notepad.exe","C:\\coo7\\wizard.txt"};
Process child = rt.exec(callAndArgs);
However, oif I try to launch a MS Word application, it asks for the entire path of WINWORD.exe, (unlike just specifying notepad.exe as the first argument in String[] callAndArgs) and this can vary from one machine to another.. how do I get around this?
The foll. code snippet works but the complete path of where WINWORD.exe might be installed on any machine, is not fixed:-(
Runtime rt = Runtime.getRuntime();
String[] callAndArgs = {"C:\\Program Files\\Office\\Office10\\WINWORD.exe","C:\\coo7\\wizard.doc"};
Process child = rt.exec(callAndArgs);
Any idea/suggestions pls.. -
How to open an PDF file from Java Application
Hi
I am developing a GUI application in java swing.
on clicking one button, I want to open PDF file from my swing application.
Is there any API through which I can achieve this?
Tapan Maru
Sun Certified Java ProgrammerHere's a way to do it (if I understand you
correctly). Just let explorer.exe do it for you.
import java.awt.*;
public class openPDF
Desktop desktop = Desktop.getDesktop();
public openPDF()
open("test.pdf");
public void open(String path)
try
Runtime.getRuntime().exec("explorer.exe "+path);
} catch(Exception e) { System.out.println("NAI!
I! ERROR!\n"+e); }
public static void main(String[] args)
openPDF myApplication = new openPDF();
Why do you have a Desktop object as a member but instead of using it, you execute a command with Runtime (which is not platform independent!)???
-Puce -
Can i open a flase file from java application?
i want that when the user click a button on my java application,
a flash file i made (Not html)will be showen .is it an executable(*.exe?), if it is then you could try using runtime.exec() to run it, but it would not be in a window that you created
-
Write HTML Files from java application
Hello,
i have to write HTML files from a java application.
I am asking if anybody can give me a hint about a good simple solution (library) which can do some of the job for me.
i know FOP for example is good to create pdf or html from xml, but i dont want to go via xml.
the sites i need are really very simple presents emails.
body and maybe a link for next and pervious.
however, thank you in advance.
a little hint will also help :)
Sako.That, too, is my question.
Be the "server" local or remote, wouldn't JSPs still
be the easier solution? No. it will not. because you need a server. Server for a stand alone application is not esier. according to who said JSPs are easy?
Its very very difficult.
>
When answering, please clarify. I'm a bit of a newbie
here. :)To get sence about how hard is JSP, check Struts. this is very good open source Framework to simplify the JSPs. but it still complecated enough.
or Tapestry my lovely open srouce Framework.
its easier than Struts. but sill complecated because of the documentation.
All in all, using JSP is the purpose of Java in the internet. but not for me. My application will not be available in the internet, i.e. no server, i.e. no need for JSP.
i hope that helps a little. -
Different languages used while uploading file from java Application
Hi everybody,
i have a problem with multiple languages , let me clear you the question, i were developing a java application using spring ,hibernate frame works, so i got a problem while uploading a file with chinees language or other
it was saving with different format other than chiness in the database, can any one help me out ... i need the exact language when i upload the files,and when i get the data from DataBase which is in chinees language is '걨' going to be like as '???'
thank you very muchSanthosh_25 wrote:
using utf-8 characterSet, but its not showing properly
thank youOkay.. the problem with your browser settings.. (not sure)..
In firefox try to set character encoding...
go to View--->Character Encoding--->Unicode (UTF-8)..
In IE
go to View--->Encoding-->More-->Unicode (UTF-8)
set this and try. -
Bat files from java application..its urgent pls help me
hi
My java application tries to execute the bat file, the code followes
Runtime runs = Runtime.getRuntime();
runs.exec("e:/customisation/test.bat");
The bat file contains commands to copy files from one folder to another
and some dos commands, but the commands are not executing. If i tried the bat file with some exe's like notepad its working well, but not working with dos commands.
thanks in advance
nisamHi
Your batch file will be working actually. But no output will be seen in the console window.
For example I had created a batch file with the folowing code
echo This is test
copy test.bat test1.bat
pause
Even though I can't see the messages in the console, it executed when called using
Runtime runs = Runtime.getRuntime();
runs.exec("hi.bat");
where hi.bat contains the above code.
If you want to see the output messages also in the console, you have to redirect the outputstream to the current console. One such class this does is available somewhere in Java(I don't exactly remember :-( ). I think it is StreamPluginThread.java
Regards -
Running .bat files from java applications
Has anyone tried to run a .bat file from a java application?
I know I can run java commands by getting the application's runtime, but I've a number of *.bat files I like to run from the application without having to extract the commands from the .bat files.
thks,Crikey! You were answered very shortly after you posted your question, and you STILL haven't bothered to come back. And are you going to create a new userid the next time you ask a question, since bat2004 seems tied to this particular question?
-
How to print PDF file from java application?
Hi,
I have a java application that needs to print an PDF files. Could any one provide me links to tutorial/sample codes for doing this?http://onesearch.sun.com/search/onesearch/index.jsp?qt=print+pdf+files&subCat=&site=dev&qp=&chooseCat=javaall&col=developer-forums
-
Writing non-latin Character to Log file from Java application
Hi Everyone,
I'm encountering a very strange localization issue.
I'm executing the following code from a J2EE application (although the behavior is replicated exactly from a Java console application):
File testFile = new File("D:\\Temp\\blah.txt");
testFile.createNewFile();
Writer output = null;
try {
output = new BufferedWriter( new FileWriter(testFile) );
output.write( "אחד שתיים שלוש" ); // Non-Latin characters
output.write("one two three");
finally {
if (output != null) output.close();
I'm writing non-latin characters (Hebrew in my case) to the file, but these characters are written as question marks:
??? ????? ????one two three
I'm running the project with the following java arguments:
-Dfile.encoding=UTF8 -Duser.region=IL -Duser.language=he
And the Project Properties -> Compiler -> Character Encoding = UTF8
Also, the local Windows Regional Settings are set to Israel / Hebrew.
Can someone please help with this issue?
I've tried this with UTF-8 (instead of UTF8) and still no results.
I suspect this is a Java / Environment issue as it reproduces on a J2EE app and on a console app.
Any help will be greatly appreciated.
Thanks,
Tal.You should open/close it somehow at every write from different processes.
But I personally prefer different file names to your forced merging, though. -
Can't open files from an application by dragging the file from another window
In Mac os x 10.6, i was able to to open a file by simply dragging it and placing it on the 'open' Window which automatically changes the location to where the dragged file is. Ever since updating to Lion, i'd have to go folder by folder from the 'Open' window until i get to where the file is and selecting it.
iI tried it with so many applications Like When i'm sending a file via bluetooth, i tried opening a file with iTunes too by dragging to see if it'll work, it didn't. I tried uploading a Photo to facebook too by dragging it to the select photo window, it didn't work.
-
What the best way to create XML files from JAVA application?
Hi to all,
I need to edit and to create new filex in format of xml. I know to parse, but what would be the best way to do:
1. - Create new file, create like simle text file, or there is some clases that know to do it in more simple way
2.a - Edit XML file, to take some data and add it to the XML in the place I want to.
2.b - Also Edit, but not to add fields, just update some of them.
Code examples or links to samples woul be welcomed.
Best regards, Nick.I have tried working with XML directly using the Java classes but this was a pain. I then looked at DOM4J and JDOM and found JDOM easier to use.
-
How can I list open files from the same application
I often have several different files open in Word, Excel or Adobe. However only one is visible. How do I get a quick list of the other open files from an application?
Many applications have a Window menu at the top of the screen. Clicking on it will list all the open windows, as well as providing other options depending on the application.
(113485) -
Can I Open an HTMLHelp (*.CHM) File from Java GUI Application?
I ussually use Delphi to develop my applications and I can open an HTMLHelp (*.CHM) file from my application. Can you show me the ways to do it from my Java GUI applications?
Thanks for everyone.
Budi Raharjo
http://budiraharjo.blogspot.comhttp://www.google.com/search?q=java+chm
Seems like there is some 3rd party software available for that. -
Can we run EXE file/ Another Java Program from Java Application? How?
Can we run EXE file and another java program from java application?
Thanks in advanceExample running adobe acrobat
String command = "C:\\Program Files\\Adobe\\Acrobat 5.0\\Reader\\AcroRd32.exe /t "+selectedDocument+" \\\\CONTROL\\HP LaserJet 4L";
Runtime rn = Runtime.getRuntime();
Process process = rn.exec(command);
process.waitFor();rykk
Maybe you are looking for
-
InDesign CS3 crashes when I try to insert a new page
I'm working on a document that is currently 70+ pages in InDesign CS3, and whenever I try to add a new page (regardless of where I try to add the new page at within the document), InDesign crashes. I haven't experienced this issue with any other docu
-
How to change content/stacked canvases to tab canvas
Hi, I have created a form which has one content canvas and multiple stacked canvases. The content canvas displays the first page and then we hv to click on next to go to the next stacked canvas and so on. I want to try making it in tabs (tab canvas)
-
Why can I not 'go to current song' in a smart playlist anymore? Also why has the total amount of songs/time display gone?
-
Hi; I've been offered to "take care" of a friend's G4 (same model as mine), and I would like to connect them, first of all for filesharing, but - if possible - it would be great if they could share the internet connection, and even better if they cou
-
is there any function to stop the procedure for 0.01 secs?? i want that precision. thank you, regards, chintan