Open a PDF file in linux using java
Hi..
How can I open a PDF file in linux using java.
I am able to open PDF in windows and mac using this code
in Windows
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + path_of_PDF);
in mac
Runtime.getRuntime().exec("open " + path_of_PDF);
But nothing is working with linux.
Please help
Thanks
One thread is enough:
http://forum.java.sun.com/thread.jspa?threadID=5267458
Similar Messages
-
Open PDF file in linux using java
Hi..
How can I open a PDF file in linux using java.
I am able to open PDF in windows and mac using this code
in Windows
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + path_of_PDF);
in mac
Runtime.getRuntime().exec("open " + path_of_PDF);
But nothing is working with linux.
Please help
Thanksappi wrote:
Hi.. I found the JDIC binary files. There are different binaries for all the plateform. Is there any solution which is independent of plateform.Yes, and we already told you: Use JDK6, which has those libraries built into the standard class library.
How can I use these binaries in my existing project. does it work, If I place them at same place where other .class files are kept.Read the documentation of the JDIC project. I'm sure they answer this question in their FAQ. -
I cannot open any pdf files! I used to be able to. Have a mac.
I cannot open any pdf files. I used to be able to. If I open them I get a blank screen. Have a mac. Help!!!!!
Hi Charlie,
First, thanks for responding. These are mostly emails with attachments or documents that I have. I download them and once I open them the page is blank. I also cannot look at them in Preview. The same problem. I called Apple and they said they assume I have an older software version. They are going to send new software. I am not really sure this will solve my problem. If you have any suggestions, please let me know. Thanks! -
How to run SQL script file on Linux using Java ?
Hi,
I need to execute .sql file using java. I used following approach for this.
private void runScriptEvent(java.awt.event.ActionEvent evt) {
String sqlOutput = "";
String sqlPromptLines="";
String currentFunctionName = "";
if(con!=null){
String userName = jTextField4.getText();
String password = jPasswordField1.getText();
String databaseName = jTextField3.getText();
try {
String script_location = "";
ProcessBuilder processBuilder =null;
Process process = null;
//File file = new File("C:/ScriptFile");
File file = new File("./SQL_Script");
//File file = new File("E:\\install\\SQL_Script");
if(file.exists()){
File [] list_files= file.listFiles(new FileFilter() {
public boolean accept(File f) {
if (f.getName().toLowerCase().endsWith(".sql"))
return true;
return false;
int count = 0;
for (int i = 0; i<list_files.length;i++){
script_location = "@" + list_files.getAbsolutePath();//ORACLE
//currentFunctionName = list_files[i].getName();
StringTokenizer st = new StringTokenizer(list_files[i].getName(), ".");
while(st.hasMoreTokens()) {
currentFunctionName = st.nextToken();
String extention= st.nextToken();
System.out.println("Function Name = "+currentFunctionName + "\t Extention = " + extention);
processBuilder = new ProcessBuilder("sqlplus",userName+"/"+password+"@"+databaseName, script_location); //ORACLE
processBuilder.redirectErrorStream(true);
process = processBuilder.start();
BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));
String currentLine = null;
while ((currentLine = in.readLine()) != null) {
sqlPromptLines = " "+sqlPromptLines + currentLine +"\n";
count ++;
System.out.println(count+" " + currentLine);
if(currentLine.equalsIgnoreCase("Function created.")){
sqlOutput = "\n" sqlOutput currentFunctionName + " " currentLine"\n" ;
break;
}// end while
in.close();
process.destroy();
}//end for
}//end if file exists
} catch (IOException e1) {
jTextArea1.setText(e1.getMessage());
System.out.println("Script Done");
jTextArea1.append(sqlOutput);
}// end id Connection is not null
Above code working appropriate on Windows but not on Linux.
is there any changes needed ?
Regards,
Ajay
Edited by: Ajay Sharma on Nov 21, 2012 6:43 PMHi gimbal2,
about code
jTextArea1.setText(e1.getMessage());I am using this code so that the user will be prompted with a message rather than stack trace.
About the issue I am getting on linux i believe its because of following statement.
processBuilder = new ProcessBuilder("sqlplus",userName+"/"+password+"@"+databaseName, script_location); //ORACLERegards,
Ajay
Edited by: Ajay Sharma on Nov 23, 2012 12:05 PM
Edited by: Ajay Sharma on Nov 23, 2012 12:06 PM -
Problem in opening pdf file in linux
how can i open a pdf file in linux(openSuse)..i can open .doc, .xls, .pdf in windows using the code.. its working fine..
Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + path_of_PDF);like that i want to open in linux...
i would be very grateful to you and i need help..plz
plz............
Thanks in Advance....I've used code like
File path=new File("/home/RichHelp.pdf"); Runtime.getRuntime().exec("Desktop.getDesktop().open()"+path);i'm getting these errors
java.io.IOException: Cannot run program "Desktop.getDesktop().open()/home/RichHelp.pdf": java.io.IOException: error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:459)
at java.lang.Runtime.exec(Runtime.java:593)
at java.lang.Runtime.exec(Runtime.java:431)
at java.lang.Runtime.exec(Runtime.java:328)
at richwoods.MasterScreen.actionPerformed(MasterScreen.java:795)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1216)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1257)
at java.awt.Component.processMouseEvent(Component.java:6038)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2429)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Caused by: java.io.IOException: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.<init>(UNIXProcess.java:148)
at java.lang.ProcessImpl.start(ProcessImpl.java:65)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:452)
... 31 more -
Open a PDF file on a remote system with an URL
With Javascript,
I want to open a PDF file in Acrobat using an URL, I dont want open this file in a Webbrowser.
The openDoc method expects a file path, not an URL, and the getUrl method open the file in a Webbrowser.
How to do ?
David GYou will need to write a custom plugin that installs a custom file system for http (or ftp or whatever protocol(s) you plan to use).
-
Cant open a PDF file in click box
I cant open a PDF file in captivate (using a click box) it
goes out to the net and does a search - any answers?
Also I tried to use a menu builder but I cant add that to a
captivate learning object either - any answers?
Thanks in advance everyone, i really appreciate it I am still
learning this program.
Cheershi DilbertG
Thanks for the quick reply
I have the PDF file local and select it from the browse
button.
The path is absolute.
The address that IE shows is a MSN search for the PDF file
name - eg the file name is Students with learning difficulties.pdf
it goes to a MSN search and looks for Students with learning
difficulties.pdf web pages.
I test this in preview and does the above mentioned.
Do I need to save the PDF in a different location so
captivate can access it?
Thanks for the help,
Cheers -
Opening a pdf file stream using java
I am developing a web app using jsp that needs to dynamically create xml files, then using fop I convert those files into pdf's.
I would need to be able to open multiple pdf files in a row...
Here's what I have so far....this will only open the 1st file...
I don't need to open the pdf files in a web browser, it can be done in acrobat reader if needs be...
do
if ( ( ( startRec * cache) + 1 ) <= ( min( ( startRec + 1 ) * cache, recCount ) ) )
System.out.println( ( startRec * cache ) + 1 + "-" + min( ( startRec + 1 ) * cache, recCount ) );
String xmlString = xmlStart;
for ( int n=( startRec * cache ); n<min( ( startRec + 1 ) * cache, recCount ); n++ )
ViewFileDetailsBean viewBean = (ViewFileDetailsBean)listOfViewFileDetailsBean.get(n);
xmlString = xmlString + viewBean.getxMLString();
xmlString = xmlString + "/t</data>\n"; // THIS FINISHES THE XML
pdfBean.makePDF( xmlString );
response.setContentLength( pdfBean.getOutput().length );
response.setContentType( "application/pdf" );
response.getOutputStream().write( pdfBean.getOutput() );
response.getOutputStream().flush();
startRec++;
}while ( startRec <= ( recCount / cache ) );
Thanks,
GoldenEye4everI forgot to say,
We will not have write access to the server, also, the higher-ups would like to view pdf files.. rather than extracting a zip file containing pdf files...lol
Basically, the xml file that I was initally creating was getting far too large for java to handle, 190,000 records +,
so i am breaking them down to perhaps 10,000 record long xml files, to be converted to pdf
Thanks for your fast reply
GoldenEye4ever -
How to open pdf files in browser using flex
hi,
my project is having a Document explorer wchich contains pdf
files,iwant to open it in the browser.can any one tell me how to
open pdf documents using flex programming(i tried with different
thing like swf's but my client wants only pdf formatt).Another option is by calling a JSP page. This example will
open a pdf file into a new browser without displaying the download
"save" prompt.
Function to call the JSP:
private function downloadFlyer(event:Event):void {
var jspLink:URLRequest = new
URLRequest("jsp/downloadpdf.jsp?fileName=Fundraiser_flyer_2008.pdf");
navigateToURL( jspLink, "_blank" );
JSP code:
<%@ page errorPage="error.jsp" %>
<%@ page import="java.io.*" %>
<%
//Get the parameters
String downloadFileName=request.getParameter("fileName");
String fileName = application.getRealPath("/downloads/" +
downloadFileName);
File file = new File(fileName);
if (!file.exists()) {
throw new IOException("File does not exist.");
// Get the size of the file
long length = file.length();
// You cannot create an array using a long type.
// It needs to be an int type.
// Before converting to an int type, check
// to ensure that file is not larger than Integer.MAX_VALUE.
if (length > Integer.MAX_VALUE) {
throw new IOException("File too big.");
response.reset();
response.resetBuffer();
response.setContentType( "application/pdf" );
response.setHeader ("Content-Disposition", "filename=" +
downloadFileName);
//Prevent the Java error: "getOutputStream() has already
been called for this response"
out.clear();
out = pageContext.pushBody();
InputStream in = new FileInputStream(file);
OutputStream output = response.getOutputStream();
try {
int curByte=-1;
while( (curByte=in.read()) !=-1){
output.write(curByte);
} catch (IOException ioe) {
ioe.printStackTrace(System.out);
} finally{
output.flush();
in.close();
response.flushBuffer();
%> -
How to open a PDF file using NWDS or VC
Hi Frndz...
As per my requirment i need to open a PDF file on browser which PDFs are reside on R/3 and in my case EP server is on UNIX usinig either NWDS or VC ....
Thanks in Advance
Regards
Rajesh
09903726944hi,
can you put your question much more clearly? I couldnt get you properly.
Check out the following links, they may be useful
[How to Create a pdf form Using Web Dynpro - Java;
[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/805709cb-ec97-2910-04b8-f3d6303d8d3b]
[Diff - PDF view inside NWDS livecycle designer and when App. is run;
[https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/90e8e837-cc15-2a10-8db1-a87e2d29e9c9]
Regards,
Murthy. -
Opening a pdf file without using ABAP
Hi All,
Can I open a pdf file in the ITS without using ABAP
coding. I mean by using Java Script in an another
dialog/page can i open a pdf file. If anyone has got
any idea or sample code please let me know.
Thanks,
AmitabhHi,
Where exactly you want to open the file?
The most simple way would be to upload the file under MIMES and provide the URL in the corresponding ITS service.
BR,
Disha.
Pls reward points for helpful answers. -
Opening jpg/pdf files from Java
Hi,
How can I open jpg/pdf files or any file in general from Java, such that they open up in the default program in Windows?
I dont want to read in the files using Java. Just open them in their default program. Eg. PDF should open in Adobe.
thanks,
parsifalThanks both of you for answering.
You don't need to make a map. You need the "cmd /c
start" command in Windows.This is what I was missing. I looked up DOS commands to open a files in window but couldnt get it. So I thought java would have some command that equals double-clicking icons on window.
Thanks.
best,
parsifal -
Why do I keep getting a pop-up window that says install Java when I try to open a pdf file?
Why do I keep getting a pop-up window that says install Java when I try to open a pdf file?
(You can take screenshots of the windows in your computer using Alt+PrintScreen... No need to use a camera)
This is quite odd. Where did you get the Reader installer from? I would suggest uninstalling it and then downloading the installer from Adobe (here: http://get.adobe.com/reader/ ) and re-installing it. -
multiple blank firefox pages open one after the other, can't stop them. only solution is to use "force quit" I am on an iMac. Never had this until today. Has happened now 3 times! its scary/
== This happened ==
Just once or twice
== I clicked to open a pdf file on a web page (i've done this many times before on this web page with no problem) ==
== User Agent ==
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7See [[Firefox keeps opening many tabs or windows]]
You can have infinite tabs opening if you have selected Firefox as the application to handle a file if you get an ''Open with'' download window.
Firefox should not be selected as the application to handle a file and you have to remove the action that is associated with that file type.
You can delete [http://kb.mozillazine.org/mimeTypes.rdf mimeTypes.rdf] in the [http://kb.mozillazine.org/Profile_folder_-_Firefox Profile Folder] to reset all actions or set that action in Tools > Options > Applications to 'Always Ask'.
See http://kb.mozillazine.org/File_types_and_download_actions ("File handling in Firefox 3 and SeaMonkey 2" and "Reset Download Actions") -
How to open a pdf file in a web browser using jsp
Hi,
I have a problem opening pdf file in browser using jsp.the following is my code.Can anyone help me.Thanks
response.setContentType("application/pdf");
String filename="C:\\FictPos\\mypdf.pdf";
File file = new File(filename);
FileInputStream in = new FileInputStream(file);
OutputStream out1=response.getOutputStream();
byte[] buf = new byte[4096];
int count = 0;
while ((count = in.read(buf)) >= 0)
out1.write(buf, 0, count);
in.close();
out1.close();
}Don't know the problem specifically, but here are some suggestions to investigate:
Does it show anything in the page when you view source on it?
I would recommend using a servlet rather than a JSP page for this, if only for the fact the JSPs can insert carriage returns into places where you might not want them to. This might screw up the PDF file format?
Try setting the a link to the jsp, right-click and "save target as..." just to see if it gets any response at all - ie bypass the browser display.
Good luck,
evnafets
Maybe you are looking for
-
My iPhone has all the data I want, but it isn't matching my computers iTunes suddenly? How do I get them to match? I have more on phone than what is showing up in my iTunes. It is saying it is synced with another account which I don't have???? Help.
-
Process: Keynote [828] Path: /Applications/Keynote.app/Contents/MacOS/Keynote Identifier: com.apple.iWork.Keynote Version: 6.0 (1473) Build Info: Keynote-1473000000000000~1 App Item ID: 409183694 App External
-
Creation of PDF from Excel 2013 - problem with black color
Hi, I am a publisher of crossword magazine and I use Excel to write crosswords. Then I create PDF's and import them into InDesign. In past I used Adobe printer and it works fine with Excel 2000 and 2010 (only these two versions I used in past) Now
-
FM and/or method for displaying file from frontend ?
hi there, i have word-documents, excel-sheets, PDF'S, etc.......... on my frontend PC. i need a function module and/or method of class to OPEN this files. do you have any hints for me ? regards, Martin
-
Assignment of reference personnel no. for concurrent employment
Do we assign reference personnel no. for concurrent employment only? Is Reference personnel no. assigned only when the employee has more than one employment relationship in the same company in different countries?