Opening an additional console in a Java program

Is it possible to open an additional console to be used similarly to
System.in/out from a Java program?
How?
Thanks for any help!

You can create InputStream(System.in) and PrintStream(System.out/err).
regards,

Similar Messages

  • Opening a Word Document with a Java program in Windows

    When running a Java program in Windows, is it possible to have a button where when it is clicked it will open a Word document?
    If so, is it hard and can someone tell me how to do it??
    Thanks

    try this instead of Excel.exe you have to use Word.exe
    1. Declare your button
                   JButton butexlcom = new JButton("Carnet Offre");
                   butexlcom.addActionListener( new ButExlCommercial(msgout));
                   butexlcom.setBounds(215,510,110,30);
                   c.add( butexlcom );
    2. run your word document.
    class ButExlCommercial implements ActionListener {
         private JTextArea msgout;
         public ButExlCommercial( JTextArea msg) {
         msgout = msg;
         public void actionPerformed( ActionEvent e ) {
              try {
                   Runtime.getRuntime().exec("c:\\Program Files\\Microsoft Office\\Office\\Excel.exe NameWordDocument");
              catch(Exception en) {
                   msgout.append( "\n*** PROBLEME WORD ***\n" );
    }

  • How to close a open file at OS level using Java program

    I want to find a way to close a file connection at operating system (Windows 2000) level so that another program can overwrite the file. Here is the background information:
    I need to schedule a job to automatically update certain files. But, when someone is accessing the file, the update will fail until I manually close the file connection at file server ( I have the system administrator privilege). I want to write a Java program that can automatically close the open file like I do manually at file server. This program can be placed on the file server in order to the job.
    Does anyone know if there is any way in Java that can do the job?
    Thanks

    It's up to the application that opened the files to close them. There are utilities you can use to list/kill process on the machine..but you have to ask yourself WHY is this happening in the first place? It's more correct to fix the REAL problem - having your apps shut down properly - than to write a utility to close files.
    That said...java alone cannot do this. You would either have to use JNI to get native access to the system or use System.Runtime to call an executable that does the job for you.

  • How to open my computer window from a java program.....

    To open my computer window in win xp is simple from the start menu.
    i want to open it from a java program .
    any idea to open my computer from a java program or command prompt......

    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    import java.util.*;
    public class OpenExplorer{
    public static void main(String args[]){
         new OpenExplorer();
    public OpenExplorer(){
         try{
         String command = "explorer C:";
         // or String command = "cmd /c explorer C:";
         Runtime runtime = Runtime.getRuntime();
         Process process = runtime.exec(command);
         int exitVal = process.waitFor();
         System.out.println("Exit Value: " + exitVal);
         } catch(Exception e){
         e.printStackTrace();
    }

  • Open a file in a running java program via double click

    I have already implemented opening my program with the corresponding file after a double click in windows explorer or from the cmd line but how do you open a file into the program if it is already running as MS Word will open a .doc file in the current word instance if you are running it.
    Thx,
    Jim

    Implement some sort of interprocess communication in your program. If you launch an instance, it can check whether another is running and pass a message to it telling it to perform the wished action.

  • How to invoke browser from java program in Solaris ?

    Hi all,
    Is there any way by which a browser can be opened with specific URL, from a java program in solaris OS ?
    In windows I am able to do so by using "rundll32 url.dll,FileProtocolHandler".
    Thanks,
    ngs

    Well, how is a browser normally invoked on Solaris? And have a look at JDIC, maybe it helps you.

  • Open a console program via a java program

    Hello
    I don't know if this is the right forum's section for this question, but:
    I want to open a program inside my java program and I want to receive messages from this running program.
    My java program have to open a program and receive everything what this opened program prints on the screen.
    Can anyone help me?
    Everything will help: function names, examples, etc.
    Thanks!

    This should be the best resource:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • Opening a project in Eclipse by using a java program from outside..

    Hi friends,
    I have a java program which will open the Eclipse editor..now i want to open a file , in a specifeid path, in that eclipse. I completed opening the eclipse editor and also i m fetching the file which in a particular path..my problem is i couldnt open that file in eclipse by using my java program..
    i donno how to open a particulat file or proj in the eclipse from outside java prog.
    thanks,
    Krishna

    Try this:
    Error "This project contained a sequence that could not be opened" 

  • Running Java program created with Eclipse plugin fails to open report

    I created a CR 2008 report and using the Eclipse plug-in I created a Java program to drive data through the report and export the resulting reports as pdf files.
    This process works just fine if I run the Java program in Eclipse. I copied the code to a server to run the application remote.
    The program fails at the point of opening the Crystal Report. This is the error.
    D:\src>java EDIInvoice
    Current date : 2009928-
    Report output name is : D:\src\report\Invoice2009928-45462829.pdf
    com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: com/ibm/icu/util/Ca
    lendar---- Error code:-2147467259 Error code name:failed
            at com.businessobjects.reports.sdk.JRCCommunicationAdapter.<init>(Unknown Source)
    This is the code
    public class EDIInvoice {
         private static final String REPORT_NAME = "D:
    src
    CR8Invoice.rpt";
         public static void launchApplication() {
         try
            FileInputStream in = new FileInputStream("D:
    src
    ghxInv.txt");
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            String strLine;
            Calendar cal = new GregorianCalendar();
            int month = cal.get(Calendar.MONTH);
            int year = cal.get(Calendar.YEAR);
            int day = cal.get(Calendar.DAY_OF_MONTH);
            String today = (year + "" + (month + 1) + "" + day + "-");
            System.out.println("Current date : " + today);
    // Read the file one line at a time
            while ((strLine = br.readLine()) != null)  
                String patternStr = ",";
                String[] fields = strLine.split(patternStr);
                String EXPORT_FILE = "D:
    src
    report
    Invoice" + today + fields[1] + ".pdf";
                String Company  = fields[0];
                String Invoice = fields[1];
                String PO_number  = fields[2];
                       System.out.println("Report output name is : " + EXPORT_FILE);
         try {
    //Open report.
         ReportClientDocument reportClientDoc = new ReportClientDocument();
         reportClientDoc.open(REPORT_NAME, 0);
         System.out.println("Opened the report");
    As you can see the first 2 println statements worked fine, but the 3rd one failed. The program was not able to open the report.
    Is there a reason the code can not run without Eclipse?

    did you copy all the jar files? especially the jrcadapter.jar? please download the following sample and modify it accordingly:
    [http://www.sdn.sap.com/irj/boc/index?rid=/library/uuid/f087d31f-3e11-2c10-2cba-fcb5855f79ef]

  • Open Windows Media Player through Java program

    I need to open a video and some music in windows media player... but I don't know how....
    Can anybody help???

    I hav implemented windows media player using JSP....i am sending code
    However for java program i do not know
    <html>
    </body>
    <!-- begin embedded WindowsMedia file... -->
          <table border='0' cellpadding='0' align="left">
          <tr><td>
          <OBJECT id='mediaPlayer' width="320" height="285"
          classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95'
          codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701'
          standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>
          <param name='fileName' value="c:\abc.wmv">
          <param name='animationatStart' value='true'>
          <param name='transparentatStart' value='true'>
          <param name='autoStart' value="true">
          <param name='showControls' value="true">
          <param name='loop' value="true">
          <EMBED type='application/x-mplayer2'
            pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'
            id='mediaPlayer' name='mediaPlayer' displaysize='4' autosize='-1'
            bgcolor='darkblue' showcontrols="true" showtracker='-1'
            showdisplay='0' showstatusbar='-1' videoborder3d='-1' width="320" height="285"
            src="c:\abc.wmv" autostart="true" designtimesp='5311' loop="true">
          </EMBED>
          </OBJECT>
          </td></tr>
          <!-- ...end embedded WindowsMedia file -->
        <!-- begin link to launch external media player... -->
            <tr><td align='center'>
            <a href="http://servername/path/to/media.file" style='font-size: 85%;' target='_blank'>Launch in external player</a>
            <!-- ...end link to launch external media player... -->
            </td></tr>
          </table>
    </body>
    </html>

  • How can I stop running java program in console ?

    Hi , my name is Luck , I will explain :
    - I have created java script which execute commands from cmd level
    - In java script I'm starting *. bat file which retrieve information from system example : hostname > C:\test and then I'd like to load from the file C:\test this host name example : MyComputer
    but the problem is that my script execute reading from the file C:\test before any information will be delivered to this file , how can make a system to wait until bat file will finish doing its task , please , if you know the answer post me back , thank you

    I have created java script which execute commands
    from cmd levelI'd be surprised if you did. You probably wrote a Java program. I never heard of Javascript being run from the console.
    - In java script I'm starting *. bat file which
    retrieve information from system example :
    hostname > C:\test and then I'd like to
    load from the file C:\test this host
    name example : MyComputer???
    but the problem is that my script execute reading
    from the file C:\test before any information will be
    delivered to this file , how can make a system to
    wait until bat file will finish doing its task ,
    please , if you know the answer post me back , thank
    youWhat are you talking about? This isn't Java, this isn't Javascript, I have no idea what it is. It's already difficult to understand your problem description.

  • Opening Default TextEditor Independent of OS through Java Program

    Hi All,
    I need a small help, I have a requirement in my program. I need to open default Text Editor of OS through Java Program independent of OS.Now i am using java 5.0. Is this facility available in java 5.0 API or I have to use any third party API is required, if yes then please suggest�
    I apologize for my poor English...
    Thanks in Advance�
    RamaDevi B.

    The concept of a default text editor is not OS-independent. Linux doesn't have one. (Yes, a shell can have one via the EDITOR environment variable, but you can invoke a jar from a window manager's desktop without running a shell. Nor does mailcap really count, because that defines a text viewer rather than a text editor). As far as I'm aware, OS X doesn't have one. In fact, Windows is the only OS which I know to have one.

  • Help--How can I open only one java program at one time?

    How can I open only one java program(same program) in Windows at one time?

    In Java 1.5, you can use the JVM's own monitoring APIs to examine what other JVMs are running on the system, and what applications they're running.
    It's general and powerful, but complex. The socket/file/whatever approach is cleaner, and probably more suited to your usage.
    Don't bother trying to use the Windows task manager for this sort of thing. You have to write messy native code, and it isn't reliable after all that anyway.

  • How to compile and run java program at command console

    hi there
    can anyone tell me how to compile and run a java program at command console? I have installed JRE 1.3.1, and also have installed JBuilder 5 if it helps.

    try this
    System.out.println("Enter your Name : ");
    BufferedReader console = new BufferedReader( new InputStreamReader( System.in ) );
    String s = console.readLine();
    System.out.println("Hello : "+ s+" !" );

  • Opening a URL from a Java Program

    Hi all,
    Can I open Internet Explorer and invoke a URL from a Java Program. If it can be done, could someone please give a code for that.
    Thanks in advance.

    Did you try it like "start \"http://java.sun.com\""
    or maybe
    "start 'http://java.sun.com'"I've no idea whether that will work, but it would be the first thing I'd try.

Maybe you are looking for

  • Why does automator crash under MacOS X 10.8?

    All of the automation actions and services that worked so well in Lion now fail silently under Mountain Lion.  As well, the Automator.app crashes on launch -- every time.  Has 10.8 killed MacOS X automation entirely or can I fix this?

  • WRT54GS - Web page loads slow or not at all

    My parents have two wireless laptops accessing their WRT54GS.  Both receive excellent signal strength.  Web pages load at normal speed for the first unit to access the internet on their network.  However, the web pages will take forever or not load a

  • Nokia N8-00 Problems

    I chose the N8 for the specification & I believed Nokia must have corrected all the faults in the previous N series handsets, especially with the arrival of Bells software but I am deeply disappointed. I have two identical handsets and have used one

  • Extensions and file handling in migration context

    Hello, background: i just migrated one of our apple machines from ppc to intel hardware. So at the moment both machines are still available in the same state. question: how knows mac os x how it should handle a file by default ? Or better the display

  • Share option missing from "Videos" Ios8. Cant find home movies only purchased.

    Sharing is on Videos and Music Sharing is on iTunes. Wanted to show my 6 year old doing ice bucket challenge but Apple tv wouldn't see PC. So I was going to reset family sharing and Apple in its infinite wisdom made it so it turns off the remote capa