GetRuntime can NOT exec very simple C executable

Dear all,
I compiled the following very simple C program as echo.exe in windows, now I want to use
Process process = Runtime.getRuntime().exec("echo");
to output all results from echo.exe to a JTextArea.
So I created an
inputStream = new BufferedInputStream(process.getInputStream());
and then use a thread to detect any outputs from the thread:
// inside run
while (inputStream.available()==0) {
     Thread.currentThread().sleep(100);
byte[] bytes = new byte[inputStream.available()];
inputStream.read(bytes);
/* output is a JTextArea */
output.setText(new String(bytes));
Now the problem is: it even can not print out "Prompt>", until I type "quit" to exit the program, and then print out everything save from the start.
I tested again and again by modifing the C program and noticed that the problem here is gets( line ) - seems it blocks for ever -> if I do not use this line, everything is ok. I do not know why it even does not execute printf("\nPrompt> "); going to gets(line); ?
Anything wrong here? Any suggestions?
Note: Just ignore any inputs from user now, I only needs to display "Prompt>" in JTextArea, since this is my major problem.
Many thanks!
/* echo.c*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
  char line[1024];
  while(1) {
    printf("\nPrompt> " ) ;
    gets( line ) ;
    if(strcmp(line,"quit") == 0) {
      break;
    else {
     printf("%s", line);
  return 0;
}

I haven't tried this but it should work. The output stream
should be obtained if you want to break out of the gets() statement.
when you write to the stream always include the '\n' character.
Process process = Runtime.getRuntime().exec("echo");
inputStream = new BufferedInputStream(process.getInputStream());
// inside run
String str = inputStream.readLine();
output.setText(str);
PrintWriter out = new PrintWriter(process.getOutputStream());        
out.println("quit\n");  
out.flush();
out.close();
out = null;
/* echo.c*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
  char line[1024]; 
  while(1)
    printf("Prompt>\n" );   
    gets( line ) ;   
    if(strcmp(line,"quit") == 0)
      break;   
    else
      printf("%s", line);   
  return 0;

Similar Messages

  • Can't run very simple DOM parsing source on my machine - please help :(

    Hi Guys,
    I am trying to run the following very simple program on my machine to parse a very simple XML file.
    It just returns Document object NULL.
    Same code is working fine on another machine.
    Note: there is no silly mistake. i have valid xml file at valid place.
    Please help.
    import org.apache.xerces.parsers.*;
    import org.w3c.dom.*;
    import org.xml.sax.*;
    import java.io.*;
    class XML
         public static void main(String[] args)
              try{
                   String caseFile = "c:\\case-config\\config.xml";
                   DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                   factory.setValidating(true);
                   DocumentBuilder builder = factory.newDocumentBuilder();
                   Document doc = builder.parse(caseFile);
                   System.out.println("\n\n----" + doc);
              }catch(Exception e)
                   e.printStackTrace();
    }

    You could also work with JDOM, which I find easier to use than regular DOM:
    import org.xml.sax.InputSource;
    import java.io.FileReader;
    import org.jdom.input.SAXBuilder;
    import org.jdom.Document;
    String caseFile = "c:/case-config/config.xml";
    InputSource inputSource = new InputSource(new FileReader(caseFile));
    SAXBuilder builder= new SAXBuilder();
    Document document = builder.build(inputSource);Just an alternate suggestion.

  • Can not read authorization object in execute Query

    hello:
       Now I create a authorization object ZSALR, include Activity,Sales Group,Sales Office.                     Activity = Display ,Execute;
    When Sales Group = S_N and Sale Office = S_SX. I execute Query restrict by Sales Group and Sale Office.
    Warning message"You do not have authorization to read to ZSALR"
    When Sales Group = * and Sale Office = *. I execute Query OK, and display all infomation. and explain "S_N" and "S_SX" can display in middle part in Query.
    Hope someone can tell me how to solve the error.
    Regards&Thanks!

    This occurs because , something in the class has changed . Every class has a serial id associated with . It is unique. even if a member var changes , this id will change .
    You are trying to deserialize a serialised object with a changed version of the class .
    You can see the serial id using "serialver" utility provided with jdk in bin directory

  • Why the ejb can not pass the complie?

    I just use the work shop to create a simple ejb(SampleEJB.ejb) like:
    package SampleEJB;
    import javax.ejb.*;
    import weblogic.ejb.*;
    * @ejbgen:session
    * ejb-name = "Sample"
    * @ejbgen:jndi-name
    * remote = "ejb.SampleRemoteHome"
    * @ejbgen:file-generation remote-class = "true" remote-class-name = "Sample"
    remote-home = "true" remote-home-name = "SampleHome" local-class = "false" local-class-name
    = "SampleLocal" local-home = "false" local-home-name = "SampleLocalHome"
    public class SampleEJB
    extends GenericSessionBean
    implements SessionBean
    public void ejbCreate() {
    // Your code here
    * @ejbgen:remote-method
    public void Hello(){
              System.out.println("Hello");
    * @ejbgen:remote-method
    public void Hello2(){
              System.out.println("Hello2");
    but when i build it. The compiler give me error:
    ¾¯¸æ: SampleEJB.java:14: ÕÒ²»µ½ JNDI Ãû³Æ¡£
    [Info:] Creating D:\DOCUME~1\Yong\LOCALS~1\Temp\/wlw_SampleEJB_build\SampleEJB\SampleHome.java
    [Info:] Creating D:\DOCUME~1\Yong\LOCALS~1\Temp\/wlw_SampleEJB_build\SampleEJB\Sample.java
    [Info:] Creating D:\DOCUME~1\Yong\LOCALS~1\Temp\/wlw_SampleEJB_build\META-INF\ejb-jar.xml
    [Info:] null [Bean] MAKE CLASS NAME G:SampleHome P:SampleEJB N:SampleHome
    [Info:] null [Bean] MAKE CLASS NAME G:Sample P:SampleEJB N:Sample
    [Info:] Creating D:\DOCUME~1\Yong\LOCALS~1\Temp\/wlw_SampleEJB_build\META-INF\weblogic-ejb-jar.xml
    [Info:] Creating D:\DOCUME~1\Yong\LOCALS~1\Temp\/wlw_SampleEJB_build\ejbgen-build.xml
    SourceLoader roots: 10
    post-ejbgen:
    ¾¯¸æ: EJBGen ok. Compiling...
    Compiling 3 source files to D:\DOCUME~1\Yong\LOCALS~1\Temp\wlw_SampleEJB_build
    ¾¯¸æ: All files compiled. Running ejbc...
    <2004-5-3 ÏÂÎç16ʱ20·Ö17Ãë CST> <Warning> <EJB> <BEA-010212> <The EJB 'Sample(Jar:
    D:\DOCUME~1\Yong\LOCALS~1\Temp\wlw_SampleEJB_build)' contains at least one method
    without an explicit transaction attribute setting. The default transaction attribute
    of Supports will be used for the following methods: remote[Hello2(), Hello()]
    >
    SourceLoader roots: 60
    D:\DOCUME~1\Yong\LOCALS~1\Temp\wlw_SampleEJB_build\SampleEJB\Sample_vngkt3_HomeImpl.java:13:
    cannot resolve symbol
    symbol : class SampleHome
    location: class SampleEJB.SampleEJB
    implements SampleEJB.SampleHome, weblogic.utils.PlatformConstants
    ^
    D:\DOCUME~1\Yong\LOCALS~1\Temp\wlw_SampleEJB_build\SampleEJB\Sample_vngkt3_HomeImpl.java:69:
    cannot resolve symbol
    symbol : class Sample
    location: class SampleEJB.SampleEJB
    public SampleEJB.Sample create ()
    ^
    D:\DOCUME~1\Yong\LOCALS~1\Temp\wlw_SampleEJB_build\SampleEJB\Sample_vngkt3_EOImpl.java:15:
    cannot resolve symbol
    symbol : class Sample
    location: class SampleEJB.SampleEJB
    implements SampleEJB.Sample, weblogic.utils.PlatformConstants
    ^
    D:\DOCUME~1\Yong\LOCALS~1\Temp\wlw_SampleEJB_build\SampleEJB\Sample_vngkt3_HomeImpl.java:73:
    cannot resolve symbol
    symbol : class Sample
    location: class SampleEJB.SampleEJB
    return (SampleEJB.Sample) super.create(md_ejbCreate);
    ^
    4 errors
    ´íÎó: ERROR: Error from ejbc: Compiler failed executable.exec
    ´íÎó: ERROR: ejbc couldn't invoke compiler
    BUILD FAILED
    ´íÎó: ERROR: Error from ejbc: Compiler failed executable.exec
    ´íÎó: ERROR: ejbc couldn't invoke compiler
    Why? who can give me a hand

    I met the same problem. I am a newbie, but why weblogic even can not build a simple startup ejb project?

  • Very slow "launch executable" compared to shortcut

    In a Zenworks 11.2.3 environment with all Win7 workstations:
    In trying to debug a Lotus Notes upgrade package, we separated out the program
    launch itself. The launch, a single action, is very simple: Launch Executable
    that has the command line "c:\program files\IBM\Lotus\Notes\notes.exe" with the
    working directory set as "c:\programs files\IBM\Lotus\Notes" on 32-bit Win7.
    The working folder and command line contain "C:\program files (X86)" (etc.)
    instead, on 64-bit Win7 stations.
    In both cases, the launch action is very slow, and sometimes hangs the Notes
    client for a very long time (more than a few minutes).
    If I create a shortcut on the desktop with exactly the same for command line
    and working directory, it launches vastly quicker -- no more than a few seconds
    to fully open.
    The environment is one where management wants to launch only out of the NAL
    (Zenworks window) and not from a shortcut on the desktop. But the performance
    issues are very apparent.
    Why is it so much faster to launch from the desktop shortcut than via Zenworks?
    What can I look for to pinpoint the source of the slowness, and is there
    anything else that I can do other than putting a direct program shortcut on the
    desktop? Is this a known issue?
    Thanks.
    -- DE

    It is possible that a "Search" (or Plural) are taking place and hitting
    the network.
    Not quite sure why F: is getting appended, but it could impact things.
    On 3/14/2014 1:50 PM, DE wrote:
    > The only difference in the paths (and odd enough as it is) is that the
    > one run from CMD.exe directly has "F:" appended to the end; F: is (I
    > didn't set this up) set to SYS:\PUBLIC on a Novell server. Whether
    > there's anything in that location that would interefere, well, I haven't
    > been able to fully investigate yet. But if anything, I would've
    > expected just the opposite.
    >
    > Thanks. I am trying to put more definition around the issue before I go
    > further with questions.
    >
    > -- DE
    >
    >
    > Craig Wilson wrote:
    >> Create a Bundle that run CMD.exe as the logged on user.
    >> From THAT cmd.exe bundle's command-line session, just type "path".
    >>
    >> Then from a Std CMD.exe session, type "path".
    >> Do they look the same?
    >>
    >> Echo the results of "set" to a file from both.
    >> Do they match?
    >>
    >> On 3/11/2014 9:04 PM, DE wrote:
    >>> In a Zenworks 11.2.3 environment with all Win7 workstations:
    >>>
    >>> In trying to debug a Lotus Notes upgrade package, we separated out the
    >>> program launch itself. The launch, a single action, is very simple:
    >>> Launch Executable that has the command line "c:\program
    >>> files\IBM\Lotus\Notes\notes.exe" with the working directory set as
    >>> "c:\programs files\IBM\Lotus\Notes" on 32-bit Win7. The working folder
    >>> and command line contain "C:\program files (X86)" (etc.) instead, on
    >>> 64-bit Win7 stations.
    >>>
    >>> In both cases, the launch action is very slow, and sometimes hangs the
    >>> Notes client for a very long time (more than a few minutes).
    >>>
    >>> If I create a shortcut on the desktop with exactly the same for command
    >>> line and working directory, it launches vastly quicker -- no more than a
    >>> few seconds to fully open.
    >>>
    >>> The environment is one where management wants to launch only out of the
    >>> NAL (Zenworks window) and not from a shortcut on the desktop. But the
    >>> performance issues are very apparent.
    >>>
    >>> Why is it so much faster to launch from the desktop shortcut than via
    >>> Zenworks? What can I look for to pinpoint the source of the slowness,
    >>> and is there anything else that I can do other than putting a direct
    >>> program shortcut on the desktop? Is this a known issue?
    >>>
    >>> Thanks.
    >>>
    >>> -- DE
    >>
    >>
    Craig Wilson - MCNE, MCSE, CCNA
    Novell Technical Support Engineer
    Novell does not officially monitor these forums.
    Suggestions/Opinions/Statements made by me are solely my own.
    These thoughts may not be shared by either Novell or any rational human.

  • The scanner of my MX7600 in Windows 8.1 can not do half of what it did in Windows 7. When fixed

    I just replaced my old desktop PC that was running Windows 7 because it stopped working. My new desktop PC is running Windows 8.1. I downloaded the new MX7600 drivers from the Canon website for Windows 8.1, and I discovered the scanner driver can not scan a double sided document in the document feeder. It says it can scan a single side only. If I scan from the flatbed (platen), it scans only one page and then it exits from the software. I can not find a way to scan a multiple page document on the document glass into a single file. And the driver can not create a PDF file. If I use the scanner controls to create a PDF file, the scanner driver discards the file. The Properties say the driver response to Save PDF File is Do Nothing. When will the Windows 8.1 drivers be updated to restore the functionality I had in Windows 7? Also, I spent 12 hours trying to download the User Manual from the Canon website, and I finally figured out the Download button on the website is only downloading the website page instead of the manual. So the website can not download a simple PDF file properly. When will all of this be fixed?

    Try this
    go into the control panel (hover in the lower right corner to bring up the menu that leads you there)
    go to programs, add/remove programs
    uninstall iTunes, apple mobile device service, apple application support
    then go out and redownload and reinstall iTunes. Try again to sync
    There seems to be something where an iTunes update doesn't write over all the drivers. The only way to m ake it write the right drivers is to delete the old ones and force iTunes to start over.
    You won't lose any of your music.

  • Download error (8003) can not download all purchased content - Please help?

    I have tried everything short of deleting my apple tv and starting again (already done the soft resets).
    My recently purchased products only downloaded in part... spent $300 on content much of which I can not watch = very annoying.
    Laptop is nearly full, so downloading to that and syncing is not really an option... just want thew apple tv to do what is advertised.
    PLEASE SOMEONE HELP
    thanks
    Fiona K

    try this, I could not find anything specific about that error code:
    Solution
    Deleting the cached video files of the download, and starting the download again from the beginning, often will resolve this issue.
    To find the cached video downloads:
    1. Navigate to the downloads folder on your system. This folder can be found in the following locations:
    Mac:
    ~/Music/iTunes/iTunes Music/Downloads
    Note: The tilde (~) refers to your Home directory.
    Windows Vista:
    \Users\username\Music\iTunes\iTunes Music\Downloads\
    Windows XP and 2000:
    \Documents and Settings\username\My Documents\My Music\iTunes\iTunes Music\Downloads\
    2. Locate the folder that contains the cached video file for this purchase.
    In Windows Vista, the folder will be named for the purchased video, and the name will end with .tmp.
    Example: The Dundies.tmp
    In Windows XP and Windows 2000, the folder will be named for the purchased video, and the name will end with .m4v.tmp.
    Example: The Dundies.m4v.tmp
    3. Move the .tmp folder for the affected purchased video to the Trash or Recycle Bin.
    4. Open iTunes.
    5. From the Store menu, choose Check for Purchases.
    6. Enter your account name and password and click the Check button.

  • HT3775 The document "EK000011.AVI" could not be opened. A required codec isn't available.  Can anyone tell in very simple terms what I need to do?   I am trying to open video files to a mac

    The document “EK000011.AVI” could not be opened. A required codec isn't available.  Can anyone tell in very simple terms what I need to do?   I am trying to open video files to a mac and the aformentioned message comes up

    Download and install the free VLC: http://www.videolan.org/vlc/download-macosx.html
    It runs a multitude of file formats.

  • Why??? Simple snapshot can not refresh automatically, but can refresh manually.

    Server 1 : Oracle 7.3.4 (as a Master site)
    Server 2 : Oracle 7.3.4 (as a Snopshot site)
    Client PC: SQL*Plus (Oracle 7.3.4 Client)
    Step 1: on Client PC, start 2 SQL*Plus dialog Windows,
    one(Window A) for <Server 1> , another(Window B) for <Server 2>;
    Step 2: on <Window A> do:
    SQL>connect scott/tiger@Server1
    SQL>CREATE SNAPSHOT LOG ON scott.dept ;
    SQL>select * from dept;
    DEPTNO DNAME LOC
    10 AAAAAA AAAAA
    20 BBBBBB AAAAA
    30 CCCCCC AAAAA
    Step 3: on <Window B> do:
    SQL>connect scott/tiger@Server2
    SQL>CREATE DATABASE LINK oracle USING 'Server1';
    SQL>CREATE SNAPSHOT all_dept REFRESH fast
    start with sysdate NEXT SYSDATE+1/(24*60)
    AS SELECT * FROM scott.dept@oracle;
    -- refresh interval: 1 minute
    SQL>select * from all_dept;
    DEPTNO DNAME LOC
    10 AAAAAA AAAAA
    20 BBBBBB AAAAA
    30 CCCCCC AAAAA
    Step 4: on <Window A> do:
    SQL>insert into dept values (50,'MMMMMM','NNNNN');
    SQL>commit;
    SQL>select * from dept;
    DEPTNO DNAME LOC
    10 AAAAAA AAAAA
    20 BBBBBB AAAAA
    30 CCCCCC AAAAA
    50 MMMMMM NNNNN
    <one or two minutes later ... ... >
    Step 5: on <Window B> do:
    SQL>select * from all_dept;
    DEPTNO DNAME LOC
    10 AAAAAA AAAAA
    20 BBBBBB AAAAA
    30 CCCCCC AAAAA
    conclusion: Simple snapshot can not refresh automatically ???????
    SQL>exec DBMS_SNAPSHOT.REFRESH( list => 'all_dept',method => 'F');
    SQL>select * from all_dept;
    DEPTNO DNAME LOC
    10 AAAAAA AAAAA
    20 BBBBBB AAAAA
    30 CCCCCC AAAAA
    50 MMMMMM NNNNN
    conclusion:Simple snapshot can refresh manually.
    How to solve this problem?????
    Thank you very much
    Zhang Ming-an

    When you are manually refreshing the snapshot as scott/tiger, and your database link was defined with a 'connect to/identified by ' clause, your login credentials will be scott/tiger. When the refresh happens from the job queue, it does not use those credentials, It uses some default set. What you should probably do is:
    1. create public database link Oracle using 'server1';
    2. as scott/tiger, create database link Oracle connect to scott identified by tiger;
    3. your automatic refresh should work now.

  • Very simple, but not working Table to Flat File

    I'm new to ODI, but I am having too much difficulty in performing a very basic task. I have data in a table and I want to load the data to a flat file. I've been all over this board, all over the documentation, and all over the Googles, and I can not get this to work. Here is a run down of what I have done thus far:
    1. created a physical schema under FILE_GENERIC that points to my target directory
    2. created a logical schema that points to my new physical schema
    3. imported a test file as a model (very simple, two string columns, 50 chars each)
    4. set my parameters for my file (named columns, delimited, filename resource name, etc.)
    5. created a new interface
    6. dragged my new file model as the target
    7. dragged my source table as well
    8. mapped a couple of columns
    9. had to select two KMs: LKM - SQL to SQL (for the source) & IKM - SQL to File Append (for the target)
    10. execute
    Now, here is where I started hitting problems. This failed in the "load data" step with the following error:
    +7000 : null : java.sql.SQLException: Column not found: C1_ERRCODE+
    I found a note on the forum saying to change the "Staging Area Different From Target" setting on the Definition tab. Did that and selected the source table's schema in the dropdown, ran again. Second error:
    +942 : 42000 : java.sql.SQLException: ORA-00942: table or view does not exist+
    This occurred in the "Integration - insert new rows" step.
    The crazy thing is that in a step prior to this ("Export - load data"), the step succeeded and the data shows up in the output file!
    So why is ODI trying to export the data again? And why am I getting an ORA error when the target is a file?
    Any assistance is appreciated...
    A frustrated noob!
    Edited by: Lonnie Morgan (CALIBRE) on Aug 12, 2009 2:58 PM

    I found the answer. But still not sure why this matters...
    Following this tutorial, I recreated my mapping:
    [http://www.oracle.com/technology/obe/fusion_middleware/ODI/ODIproject_table-to-flatfile/ODIproject_table-to-flatfile.htm]
    I was still getting the same error. I reimported my IKM and found that the "Multi-Connections" box was unchecked before and now it was checked. I may have unchecked it in my trial & error.
    Anyway, after running the mapping again with the box checked, the extract to a file worked.
    So, I'm happy now. But, I am also perturbed with the function of the this checkbox and why it caused so much confusion within ODI.

  • Can anyone recommend a simple Notes/To Do List app

    Hello,
    I am going crazy looking for a very simple To Do List / Notes app for my iPhone that does what I want it to do. I have spent hours in the Apps store and downloaded over 12 so far, and have not found the right one. Can anyone recommend one that:
    -allows for unlimited lists (To Do Home; To Do Out; Grocery List; Xmas Gift List etc).
    -allows you to manually SORT these lists by dragging them above or below the other items.
    -allows you to enter unlimited items (or a large number of items) within each list
    -allows for more than one line of text for each list item (not one line with ". . . ."after it)
    -allows you to manually SORT these sublist items.
    -opens directly to the page with all lists
    -is attractive (even a cute, "mom" way is fine)
    -has the auto spelling corrector
    I don't care about due dates, syncing with calendars or any other fancy stuff. I basically want it to do what the basic yellow Notes app does, but just with sorting capability.
    Thank you very much!
    Sarah B

    If a site is sending you spam, it has nothing to do with browsing the web; they can't track you down or discover your email address or anything about you, so you don't need a proxy server. They got your email address somewhere, so if your email provider is Gmail or even Yahoo! Mail, you can block them from sending based on their domain and then you won't see anything from them. If your email provider is your ISP, they can block those for you if you call them and ask them to do it.
    Mulder

  • FOR UPDATE causing query to take very long to execute.. What can we do ??

    SELECT cell_data
    FROM csv_workfile
    WHERE cell_row = p_r
    AND cell_column = p_c
    FOR UPDATE;
    this is our query. it take very long to execute.
    wat can we do to get it working properly.
    this is real real urgent .
    Ragards

    Hi,
    first ask yourself if a SELECT FOR UPDATE is really necessary. If so, try to use an FOR UPDATE OF <attribute>. If there are many users accessing and updateing this table try NOWAIT Option. Your process will not be blocked on case of another lock. You will get error ORA-00054 and can do other things while waiting.
    Keep in mind that locks will only released after COMMIT.
    But remember to ask yourself. Row locking can be very time consuming. If you can avoid it.
    Bye,
    Holger

  • I am using iPhoto '09 Version 8.1.2 but can not use iCloud with it. I've looked for updates in iPhoto and iLife'11 but no luck. Suggestions very welcome.

    I am using iPhoto '09 Version 8.1.2 but can not use iCloud with it. I've looked for updates in iPhoto and iLife'11 but no luck. Suggestions very welcome.

    No you won't necessarily lose your photos when upgrading but it's very very unwise not to back up first. Backing up is like using a seat belt in a car. You can drive without one for years and have no issues, but if you do have a problem the outcome will be a lot worse. So, too, with back ups. And upgrading is one of those times when the risks of a problem are higher.
    Most Simple Back Up:
    Drag the iPhoto Library from your Pictures Folder to another Disk. This will make a copy on that disk.
    Slightly more complex: Use an app that will do incremental back ups. This is a very good way to work. The first time you run the back up the app will make a complete copy of the Library. Thereafter it will update the back up with the changes you have made. That makes subsequent back ups much faster. Many of these apps also have scheduling capabilities: So set it up and it will do the back up automatically.
    Example of such apps: Chronosync - but there are many others. Search on MacUpdate or the App Store

  • Very simple Q !! but not for me..

    hello,
    i know its a very simple Q for some people but i m not getting any solution to it...
    the prob is that when i call ActionEvent by pressing two or more buttons the button that has produced the event is checked by using getActionCommand() but how can i check for two or more TextFields or TextAreas calling same ActionListener there is no getActionCommand() for TF n TA... i tried giving names to these components by using setName() n checking the components name in actionPerformed() but thats not working...
    plz help me out... atleast this wud clear my basics....

    Perhaps your use of setName() was not correct - it seems like it should work.
    Another alternative is to provide the ability for your ActionListener to compare the object that is the source of the event to the TextFields.
    Or, use a separate ActionListener.

  • I can not use the Runtime.exec() to open a file

    hi,
    i use java to open a pdf file like this:
    Runtime.getRuntime().exec("start c:/example.pdf");
    it works ok,but when i use java web start it do nothing,
    pls help me,why it can not work.
    thanks!

    I'm doing this with my app (getting access to the local filesystem and launch applications) and it works just fine.
    Things to do:
    1)
    Make sure your app is signed.
    (I used jarsigner to sign my jar file, comes with the j2se)
    2)
    Make sure in your .jnlp file that you are allowed to acces the filesystem, check your <security tags>
    <security>
    <all-permissions/>
    </security>
    3)
    From within the app try this to launch Acrobat Reader (win2000):
    Process pro = Runtime.getRuntime().exec("cmd.exe /C start acrord32");
    pro.waitFor();
    if (pro.exitValue() != 0)
    throw new IOException("AcrobatReader not installed");
    pro.waitFor() awaits your interaction with the filesystem, like closing an error popup dialog if os cannot find your file.
    When returning into your app, then check the exitValue. in windows, the exitvalue 1 is returned if the the file is missing. 0 if ok!
    I'm throwing an exception to handle further actions like opening a browser window with a given url to download the program.

Maybe you are looking for

  • Error while opening site studio designer

    Hi, We are getting error while opening the site studio Desiner in Server. It gives unexpected error with three options, view log, close and continue, then program just get closed. Yesterday we have upgraded site studio component and designer - Site s

  • Embedded Images moved to the bottom of the page

    Images on some pages are all being moved to the bottom of the page when displayed. i.e. - H ello world. blah blah ...20 lines later ...blah. The image is not in the top left corner of the text, but at the bottom under the text - - - but only on some

  • Why is the camera on my ipod touch 5 such low quality?

    When I take a photo of something, it is fairly blurry. However, when I tried taking a picture on my brother's IPod, it was able to focus properly and gave me great results! Does anyone know how to fix this?

  • Sending files fails last week

    I'm trying to send files from Mac Skype client to another user with Android tablet. It used to work fine for a long time, last successful transfer was May 11th, but since Sat May 16th it always fails. On my side I see immediate "Sending failed" messa

  • How to make the message invisible.

    use transction "CNMASS" to mass change the activity. but there is a message. the message no. is CN354. "No authorization for processing: WBS element  XXX" how to make this warning message "CN354" is invisible. Please explain me all the steps to be re