System Call by Java Application - [change path and run of the other progra]

public class  A {
     public static void main (String[] args)
          System.out.println("Hi");
}I do have above A.java.
I am generating A.class from it.
A.class is in the following directory :
/home/sachin/work/Sample_Directory/bin/hello_filetest/
I have another program which makes System call.
But the problem is B.java is in the different directory :
/home/sachin/work/Sample_Directory/src/hello_filetest/
public class  B {
     public static void main (String[] args) {
Process p1 = Runtime.getRuntime().exec("java A);
            BufferedReader stdInput = new BufferedReader(new
                 InputStreamReader(p1.getInputStream()));
while ((s = stdInput.readLine()) != null) {
                System.out.println(s);
{code}
        So, my question is how to change directory by system calls and execute the program
which is lying in other directory ????
Thank you.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

The following code will call javac on a .java file, which will compile it into a .class file
     public static void javacTest() {
          JFileChooser jf = new JFileChooser();
          if (jf.showOpenDialog(null) != jf.APPROVE_OPTION) return;
          File file = jf.getSelectedFile();
          File dir = file.getParentFile();
          try {
               Process p = Runtime.getRuntime().exec("javac " + file.getName(), null, dir);
               IOUtils.pipe(p.getInputStream(), System.out);
               IOUtils.pipe(p.getErrorStream(), System.out);
          catch (IOException iox) {
               iox.printStackTrace();
     }Is that what you're trying to do, or are you trying to run the compiled (.class) file? Running your .class file should be basically the same as the above, assuming that you are not using any non j2se libraries, except that you need to take into account the package (if package is x.y, you must have file in ...src\x\y\foo.class - call "java x.y.foo" from src)

Similar Messages

  • HT1386 My pad still won't show up on iTunes after I have updated to latest iTunes and run all the other 'support tests

    I am having trouble finding my iPad on iTunes even after I have done all the support tests on it :(

    Just wanted to say that you're not the only one with the problem: http://discussions.apple.com/thread.jspa?messageID=13009436

  • Calling a java application from j2ee web application

    Hi,
    I have a j2ee application in which i am making a call to a jar file which is a java application.
    Runtime a4 = Runtime.getRuntime();
    Runtime a = Runtime.getRuntime();
    String cmd[] = new String[14];
    cmd[0] = "cmd";
    cmd[1] = "/c";
    cmd[2] = "start";
    cmd[3] = "javaw";
    cmd[4] = "-jar";
    cmd[5] = CATALINA_HOME+"\\webapps\\AveksaTesting\\AveksaTestingJava\\dist\\AveksaTestingJava.jar";
    cmd[6] = SERVER_TESTS;
    cmd[7] = COLLECTOR_TESTS;
    cmd[8] = SYSTEM_TESTS;
    cmd[9] = CREATE_ORACLE;
    cmd[10] = DB_NAME;
    cmd[11] = DB_DUMP;
    cmd[12] = email;
    cmd[13] = isMIGRATE;
    try{
    java.lang.Process p = a.exec(cmd);
    Now in the called java application, i am first shutting down the tomcat server by calling shutdown.bat script and then starting it using startup.bat. But the problem i am facing is when i restart the server from java application, it says address already in use(i.e. port 8445 on which tomcat is runninng).
    Id i just call the java application and do the same operation it works fine. I guess when i am calling java from j2ee application, j2ee still has some threads holding java and not shutting down tomcat properly.
    Can anyone suggest me what can be done in this case. I have to call a java application from j2ee and restart the tomcat server many times.
    Thanks in advance
    -Vikram

    Annoyingly crossposted.
    http://forum.java.sun.com/thread.jspa?threadID=730657

  • Call a Java Application from MicroFocus COBOL (in UNIX environment)

    Hello,
    Could you please let me know, how to call a Java application from a MicroFocus COBOL application. If anyone has any code samples, that would be of great help.
    Thanks in advance,
    Tijo.

    You generally can't cause a program to be executed on a different >server. Basic security, you know. Besides this idea of having the Java >application run on a different server wasn't mentioned in your original >post. That leads me to believe we don't have the whole story.So I think you need to step back and find out what are the requirements. For example: Does your program need to start this Java application running, or is it already running and your program needs to connect to it somehow?
    My program has to start a Java class file, meaning that the Micro Focus COBOL module will call the Java class file. Will it be running on the same machine as your program, or on some other machine?
    For both cases, I would like to know the answer.a) Running on the same machine as my program is running.
    b) Running on the different machine.
    And then there are the questions about whether your program needs to have a conversation with the Java application, or whether it just needs to start it and that's all.
    COBOL program has to call a Java class by passing some parameters and Java class in turn process it and return some value back.. Kind of Request and Response model.Plenty of questions to be asked. Go and find out what they are.
    Sorry ... if I am not clear on my questions. Anyhow, thank you very much for providing the information.

  • How to remove Java Applications from "Add and Remove Programs" list?

    I have deployed my Java applications (both JWS and Applet) via JNLP with allow-offline option enabled and without installer-desc option specified.
    My questions are:
    1. An entry is added to the Add and Remove Programs list after launching the application via JNLP. Is it due to the specification of JNLP or JWS? Is there anyway to prevent this behavior?
    2. I removed my application by clearing the cache via Java Control Panel but the entry for the application is still listed in Add and Remove Programs. How can I remove the entry in the Add and Remove Programs?
    I have tried following methods but neither works:
    1.Go to Add and Remove Programs, and click [remove] button to the right of my application.
    *Warning message like 'Application cannot be uninstalled completely' is thrown.
    2.Follow instructions listed @ [Microsoft Online Support site|http://support.microsoft.com/kb/314481/en-us] to remove my application manually via Windows registry.
    *Couldn't find appropriate registry entry to delete.
    Thanks in advance!

    Hi, guys!
    This issue has been officially approved as a new bug (Bug Id: 6946221) for the JDK 1.6_20(might include any release below) release.
    It will take a couple of days for it to be shown up in the external Bug database. However, once it becomes available for viewing on external Bug database.I would like to encourage your valuable participation to vote on this bug to get it fixed ASAP by the SUN developer teams.
    Java Bug Database @
    [http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6946221|http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6946221]
    Voting for the bug @
    [http://bugs.sun.com/bugdatabase/addVote.do?bug_id=6946221|http://bugs.sun.com/bugdatabase/addVote.do?bug_id=6946221]
    Thank you for your cooperation!
    Edited by: Jay-K on Apr 23, 2010 12:14 AM

  • Calling a Java Application from MicroFocus COBOL.... (in UNIX environment)

    Hello,
    Could you please let me know, how to call a Java application from a MicroFocus COBOL application. If anyone has any code samples, that would be of great help.
    Thanks in advance,
    Tijo.

    Annoyingly crossposted.
    http://forum.java.sun.com/thread.jspa?threadID=730657

  • How to invoke Default printer of my system by using java application

    I need to invoke default printer of my system by using java application ? could u plz help me out with sample code?

    VoodooMagic.getDefaultPrinter().print();
    http://www.javaworld.com/javaworld/jw-10-2000/jw-1020-print.html
    Look for more at Google.

  • The application does not use the  screen and run in the background

    Hi
    I have downloaded a package of j2me Midlet
    from [link] here [link]
    and try to reuse the code
    but I get the following error when running the code:-
    The application does not use the screen and run in the background
    I think the error into one of these two classes
    package main;
    import javax.microedition.midlet.*;
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.media.Manager;
    import javax.microedition.media.MediaException;
    import javax.microedition.media.Player;
    import java.io.IOException;
    import java.io.InputStream;
    public class MainMidlet extends MIDlet implements CommandListener {
        private SSGameCanvas gameCanvas ;
        private Command exitCommand ;
        private Player player = null;
        public void startApp() {
      try {
           //   create new game thread
              gameCanvas = new SSGameCanvas();
              gameCanvas.start(); // start game thread
              exitCommand = new Command("Exit",Command.EXIT,1);
              gameCanvas.addCommand(exitCommand);
              gameCanvas.setCommandListener(this);
                Display.getDisplay(this).setCurrent(gameCanvas);
       catch (java.io.IOException e)
                e.printStackTrace();
            try {
                // start sounds
                InputStream in = getClass().getResourceAsStream("/resource/startfly.wav");
                player = Manager.createPlayer(in,"audio/x-wav");
                player.setLoopCount(1);
                player.start();
            catch (MediaException ex)
                ex.printStackTrace();
             catch (IOException ex)
                ex.printStackTrace();
        public void pauseApp() {
        public void destroyApp(boolean unconditional) {
            if (player != null) {
                player.close();
            System.gc();
      public void commandAction(Command command, Displayable displayable) {
           if (command == exitCommand)
                 destroyApp(true);
                 notifyDestroyed();
    package main;
    import java.io.IOException;
    import javax.microedition.lcdui.*;
    import javax.microedition.lcdui.game.*;
    public class SSGameCanvas extends GameCanvas implements Runnable {
        protected GameManager gameManager;
        protected boolean running;
        private int tick=0;
        private static int WIDTH;
        private static int HEIGHT;
        private int mDelay = 20;
        Form mainForm;
        Display display;
        //private int MaxTime;
        public SSGameCanvas() throws IOException{
            super(true);
            gameManager = new GameManager(5,5,getHeight()-10,getWidth()-10,this);
        public void start() {
                this.running = true;
                Thread t = new Thread(this);
                t.start();
        public void stop() {
            running = false;
        public void render(Graphics g) {
            WIDTH = getWidth();
            HEIGHT = getHeight();
            // Clear the Canvas.
            g.setColor(0, 0, 50);
            g.fillRect(0,0,WIDTH-1,HEIGHT-1);
            // draw border
            g.setColor(200,0,0);
            g.drawRect(0,0,WIDTH-1,HEIGHT-1);
            // draw game canvas
            gameManager.paint(g);
        public void run() {
            while (running) {
                // draw graphics
                render(getGraphics());
                // advance to next graphics
                advance(tick++);
                // display
                flushGraphics();
                try { Thread.sleep(mDelay); }
                catch (InterruptedException ie) {}
        public void advance(int ticks) {
            // advance to next game canvas
            gameManager.advance(ticks);
            this.paint(getGraphics());
    }Edited by: VANPERSIE on Jul 10, 2012 12:26 PM

    Hi Andi,
    Thanks for your reply.
    Yes, I have waited for a while and the result doesn't change.
    The Porblem here is the application is seen started in visual administrator.Only restart brings up the page back.
    Can you please suggest anything.
    Thanks and regards
    Nagaraj

  • TS3899 "cannot get mail" in iphone5 suddenly. been using iphone to check 2 email accounts for months now, one is gmail and not troubled. the other is thunderbird and i get this error message now. no settings have been changed or anything! ideas?

    hey all, I have been getting the "cannot get mail" error message on my iphone5 suddenly.
    ive been using iphone to check two email accounts for months now, one is gmail and not troubled. the other is mail from thunderbird and i get this error message now saying it is not responding. no settings have been changed or anything, it just suddenly stopped receiving mail on my device as of Tuesday afternoon.
    Does anyone have iny ideas about why? i have yet to update to the new OS7 yet, could that be it?

    'The installer has insufficient privileges to modify this file C:\Program Files (x86)\Common Files\Apple\Apple Application Support\Web kit.resources\inspector\Images\Spinner Inactive Selected.gif.'
    That one's consistent with disk/file damage. The first thing I'd try with that is running a disk check (chkdsk) over your C drive.
    XP instructions in the following document: How to perform disk error checking in Windows XP
    Vista instructions in the following document: Check your hard disk for errors
    Windows 7 instructions in the following document: How to use CHKDSK (Check Disk)
    Select both Automatically fix file system errors and Scan for and attempt recovery of bad sectors, or use chkdsk /r (depending on which way you decide to go about doing this). You'll almost certainly have to schedule the chkdsk to run on startup. The scan should take quite a while ... if it quits after a few minutes or seconds, something's interfering with the scan.
    Does the chkdsk find/repair any damage? If so, can you get an install to go through properly afterwards?

  • Webinar: Change Management and Transport in the Enterprise Portal

    <b>SAP NetWeaver Know-How Network Webinar: 
    Change Management and Transport in the Enterprise Portal
    Wednesday 21 July 2004
    11 a.m. EDT</b>
    On Wednesday 21 July, Scott Jones hosts the webinar titled <b>Change Management and Transport in the Enterprise Portal</b> as part of the ongoing SAP NetWeaver Know-How Network Webinar Series.
    Here’s how Scott describes his webinar presentation:
    “Change Management offers special challenges to administrators working in Enterprise Portal 6.0 SP2 environments.  This talk provides recommendations and tools, and defines best practices and methods for the effective transport of Enterprise Portal content, with special attention to content dependencies, tracking, and troubleshooting.   We'll also look forward to Change Management enhancements coming with Netweaver 04.”
    SDN invites you to post your questions to the presenter prior to the webinar and continue the online discussion afterward.
    <b>How to Participate</b>
    (Please go to the SDN Events page to see the article and download the PDF presentation)
    Dial-in Information:
    Date: Wednesday 21 July 2004
    Time: 11 a.m. EDT
    Within the U.S., call: +1.888.428.4473
    Outside the U.S., call: +1.651.291.0618
    Password: NetWeaver04
    WebEx Information:
    Topic: SAP NetWeaver Know-How Network
    Date: Wednesday 21 July 2004
    Time: 11 a.m. EDT
    Meeting Number: 742391500
    Meeting Password: netweaver04 (lowercase)
    WebEx Link: sap.webex.com
    Replay Information:
    A recorded replay of this call will be available for approximately three months after the webinar. Access this recording by dialing the appropriate number and using the replay access code TBD.
    Toll-free: +1.800.475.6701
    International: +1.320.365.3844
    <b>About the SAP NetWeaver Know-How Webinar Series</b>
    The SAP NetWeaver Know-How Webinar Series is driven by the SAP NetWeaver Regional Implementation Group (RIG), part of the SAP Development organization. The mission of the SAP NetWeaver RIG is to enable customers, employees, and partners to successfully implement the SAP NetWeaver solution. This SAP RIG has expertise in BI, EP, XI, and WebAS. They contribute their implementation expertise to the SDN implementation forums as well as to the SAP NetWeaver Know-How Webinar Series.
    <b>Disclaimer</b>
    SDN is not responsible for any changes to the webinar schedule. The webinar schedule may be changed or cancelled without prior notice.

    Hello,
    In the intresting document I read that for the deployement the version number mentionned in the MANIFEST.MF is very important in a clustered evironment.
    SAPnote 727180 - Version of PAR File in Manifest File
    denies this.
    Can you clear this out?
    Kind Regards
    Koen Van Loocke

  • Cookies are enabled but the commands are not stored as the problem is continuous.You return to the change window and see that the settings reverted to default.How do I make this change stick?

    A visited website says cookies need to be enabled for me to proceed.I follow the advice from Firefox and check the appropriate boxes under privacy and exit. When I try to login the same error message comes up so I repeat the routine and try again.The change is not retained as I see the default settings when I return to the page. I would love to see an APPLY button there to ensure the change will be made before clicking OK.

    Purduejaime wrote:
    I guess that is where the css for animation comes in.
    CSS transitions and animations, while very  eye-catching, do not function in IE9 or older, so be careful about adding too much of either to a menu system.
    Transitions will give you the start and stop frames so instead of a nice fluid change from one state to the other, you essentially get a rollover effect from the start style to the finish style in one step. Animations won't run at all and will only show the start frame.

  • Will Adobe Illustrator 10 install and run on the Mac OSX Snow Leopard system?

    Hello,
    I am trying to find out if Adobe Illustrator version 10 will install and run  on the Mac Snow Leopard system.  Will it?
    Also,  Will Adobe Photoshop 7 (last photoshop version before Adobe CS) run on the Mac Snow Leopard system?
    I know that many older versions of Adobe software for Mac will not work on OSX because of a change in the CPU designs. 
    Thank you.

    I don't think so. Both of them should not work on MAC Snow Leapord.
    http://support.gateway.com/s/tutorials/Tu_851038.shtml
    http://www.imaging-resource.com/SOFT/PS7/PS7.HTM

  • HT5568 Will the new update uninstall any Java applications I am currently running?

    Will the new update uninstall any Java applications I am currently running?

    Safari?  Removing your existing Java applications?  No.  That won't happen.
    What will happen is the Java run-time and the Java plug-ins that were part of Safari.  You will be using the Oracle web site, and you'll be downloading and configuring and operating and managing the Java environment and the Java plug-ins for Safari and other browsers more directly, and usually with downloads from Oracle.
    Apple deprecated Java a while back, and they're now finishing the work and the transition of support over to the folks at Oracle, and of securing OS X from attacks against stale versions of Java.

  • My Windows 7 Professional desktop system hard disk got corrupted and I took the opportunity to install an SSD for a new system disk and reinstall Windows.  The system is up and running on the SSD, with my old system disk now used for storage as it is stil

    My Windows 7 Professional desktop system hard disk got corrupted and I took the opportunity to install an SSD for a new system disk and reinstall Windows.  The system is up and running on the SSD, with my old system disk now used for storage as it is still readable.  The only Adobe product I have reinstalled so far is Reader XI but I would like to reinstall Elements 8 and Acrobat 9 without taking up more licences as both are also installed on my laptop.  Can you point me to the best way to do this?  - Thanks

    If you have the two allotted activations already and one was lost on the hard drive that failed then you need to contact Adobe Support thru chat and ask them to reset your activations.
    For the link below click the Still Need Help? option in the blue area at the bottom and choose the chat option...
    Serial number and activation chat support (non-CC)
    http://helpx.adobe.com/x-productkb/global/service1.html ( http://adobe.ly/1aYjbSC )

  • Itunes 10.6.3 - Just update to the new Itunes and the album artwork is not sticking anymore... I upload the artwork and when I change songs and go back the art is gone. Anyone with similar issue ?

    Itunes 10.6.3 - Just update to the new Itunes and the album artwork is not sticking anymore... I upload the artwork and when I change songs and go back the art is gone. Anyone with similar issue ?

    I have this issue.  Album artwork was totally fine before.  After this update, it is all messed up and even got messed up when transferred to my iphone.
    iTunes doesn't have the artwork anymore, but then iPhone has it but shows wrong artwork with wrong albums.
    Please fix!

Maybe you are looking for

  • How do I back my iphone  music up to a new computer

    I previously had the music on my iPhone 5 backed up to my old computer, this computer has now crashed and I can't access anything off it. Is there a way I can get this music from my library?

  • Help me evaluate colours

    I've built this site: http://www.judithblacklock.com On my customer's monitor all colours look pale and washed out (she has a brand new mac) and I have put this down to the monitor no having been calibrated properly. However, yesterday I added this i

  • Export of multiple artboards with only artboards' name, doesnt save to desired folder.

    when trying to export multiple artboards into files that only bear the separate artboards' name, i set up the export with the filenames with blank names so set to ".jpg" . i also choose a folder that they are to be saved to. what happens now is weird

  • Several versions of Adobe programmes

    When I install updates, my computer has several versions of each programme. E.g. Adobe Photoshop CC (2014) Adobe Photoshop CC Adobe Photoshop CC (64 bit)  Why is that? Can I delete some versions to gain more space on my computer?

  • Transferring Photoshop to new Mac w/o installation disc

    I have Photoshop from the CS4 suite (other programs are not installed) on my current Macbook Pro and am looking into purchasing a new Macbook Pro. I'd like to transfer Photoshop onto the new laptop, and fortunately my product is registered and I stil