How can I run C programs under a Java GUI?

Hi
I'm looking for some info on how to run a command line program written in another language behind a Java GUI, any advice greatly appreciated, particularly in how to transfer data between the two.
Thanks

Runtime.getRuntime().exec(...)
Transfering info is more complicated. Maybe write and read status from disk?

Similar Messages

  • How can I run Runtime.exec command in Java To invoke several other javas?

    Dear Friends:
    I met a problem when I want to use a Java program to run other java processes by Runtime.exec command,
    How can I run Runtime.exec command in Java To invoke several other java processes??
    see code below,
    I want to use HelloHappyCall to call both HappyHoliday.java and HellowWorld.java,
    [1]. main program,
    package abc;
    import java.util.*;
    import java.io.*;
    class HelloHappyCall
         public static void main(String[] args){
              try
                   Runtime.getRuntime().exec("java  -version");
                   Runtime.getRuntime().exec("cmd /c java  HelloWorld "); // here start will create a new process..
                   System.out.println("Never mind abt the bach file execution...");
              catch(Exception ex)
                   System.out.println("Exception occured: " + ex);
    } [2]. sub 1 program
    package abc;
    import java.util.*;
    import java.io.*;
    class HelloWorld
         public static void main(String[] args){
         System.out.println("Hellow World");
    } [3]. Sub 2 program:
    package abc;
    import java.util.*;
    import java.io.*;
    class HappyHoliday
         public static void main(String[] args){
         System.out.println("Happy Holiday!!");
    } When I run, I got following:
    Never mind abt the bach file execution...
    I cannot see both Java version and Hellow World print, what is wrong??
    I use eclipse3.2
    Thanks a lot..

    sunnymanman wrote:
    Thanks,
    But How can I see both programs printout
    "Happy Holiday"
    and
    "Hello World"
    ??First of all, you're not even calling the Happy Holiday one. If you want it to do something, you have to invoke it.
    And by the way, in your comments, you mention that in one case, a new process is created. Actually, new processes are created each time you call Runtime.exec.
    Anyway, if you want the output from the processes, you read it using getInputStream from the Process class. In fact, you really should read that stream anyway (read that URL I sent you to find out why).
    If you want to print that output to the screen, then do so as you'd print anything to the screen.
    in notepad HelloWorld.java, I can see it is opened,
    but in Java, not.I have no idea what you're saying here. It's not relevant whether a source code file is opened in Notepad, when running a program.

  • How can i run a program outside of Forte? (Forte and java/class files)

    im making a program with forte... and i have a bunch of class files, i form file and a java file... how can i put these in one file so poeple without forte can run it...
    thanks

    jmburns wrote:
    I am trying to do a silent install of a program I built using LabVIEW 8.5.  I also need to call an exe after the installation, so I am using the "run executable after installation" option on the Advanced tab of the installer.  I then pass the following command lines to the setup.exe:
    /qb /acceptlicenses yes /r
    This installs the LabVIEW program successfully, but does not then run the additional exe afterward.  If I run the setup.exe normally (with no command line parameters), the additional exe gets run.
    Thanks,
    Jason
    This problem is fixed in a future release of LabVIEW. Here's the CAR ID 67549 for tracking purposes.
    Message Edited by Bob P on 07-10-2008 09:10 AM

  • How can I run other programs using java program

    hi experts,
    I am trying to execute a set of commands from java program
    eg: from command prompt
    java CommandExecutor c:\winnt\notepad.exe c:\some.exe c:\onemorecommand.exe
    and inside the CommandExecutor main method..
    public static void main(String []arg)
    for(i = 0; i < arg.length; i++)
    Runtime.getRuntime().exec(arg(i));
    the above code is executing all the command one after the other, but I want to execute the above commands squentially, i.e I want to execute the second command only after finishing the first command and the third after finishing the second and so on depending upon the arguments passed, how can I acheive this...
    I have tried to use the Process which is returned by the exec(arg) method but the exitValue() returns same value before execution and after execution.
    thanks,
    krishna

    Did you try to get the process returned and then try
    process.waitFor() method. This waits for the process to finish.
    After that try the next execution

  • How can I run my program on command line?

    I'm having some trouble trying to run my program on command line.
    I get a message saying "Exception in thread
    "main" java.lang.NoClassDefFoundError: Rectangle
    <a href="http://img145.imageshack.us/my.php?image=untitled2copylh2.jpg" target="_blank"><img src="http://img145.imageshack.us/img145/3002/untitled2copylh2.th.jpg" border="0" alt="Free Image Hosting at www.ImageShack.us" /></a>
    import java.util.Scanner;
    public class Rectangle
    public static void main(String[] args)
    int width;
    int height;
    int count = 1;
    Scanner scan = new Scanner (System.in);
    System.out.println("Please enter the width of the rectangle: ");
    width = scan.nextInt();
    System.out.println("Please enter the height of the rectangle: ");
    height = scan.nextInt();
    while (count <= width)
    if(width < 1 || width > 30)
    throw new IllegalArgumentException("The numbers must be in range");
    if(height < 1 || height > 30)
    throw new IllegalArgumentException("The numbers must be in range");
    for (int star = 1; star <= height; star++)
    System.out.print("*");
    System.out.println();
    count++;
    }

    What doesn't work?
    When you type javac Rectangle.java do you get error messages? Does it create the file Rectangle.class? If yes, type java Rectangle and your program should run. If you get an error post it but if you followed earlier advice you should be able to solve the problem yourself.

  • How can I run Windows XP under 10.10.2?

    While I seldom use XP, there are times I need a Windows OS.  I run OX 10.10.2 on my late 2012 iMac, and until I updated to Yosemite, I was running under Parallels.  I deleted Parallels as I wished to upgrade it, and have lost my Windows OS ability.  Any help out there? 

    When you deleted Parallels, did you also delete the XP virtual machine you'd run using Parallels? If not, Kurt Lang's advice to reinstall Parallels will solve your problem. Or, you can install VMware Fusion, which can also use your VM.

  • How can I run a program at shutdown

    I want a program to run automatically at shutdown (or logout, since this computer has a single user...so I think that will work).
    I have searched for an answer, but I can't find it. I can find startup items, but not shutdown items.
    Anyone?

    Create a 'Stay Open' AppleScript app containing only a quit handler (i.e. no idle handler):
    on quit
        -- desired actions here
        continue quit
    end quit
    (Don't omit "continue quit"). Put it in your Login Items. It will stay running but consuming no CPU and will be triggered when you log out or shutdown.
    =-=-=-=-
    You could make it dual purpose:
    say "Good to see you back [[[emph -]]]brian"
        -- or anything else at login
    on quit
        -- desired actions here
        continue quit
    end quit

  • Doubt in AXIS-Exception in thread "main" . how can i run this program

    hi
    I am new to axis., I done few webservice program using Jwsdp
    i can't resolve the reason for this exception.
    I have set all the classpath and other path variable that is necessary for axis .,
    I got this example from http://javaboutique.internet.com/tutorials/Axis/index.html
    Can any one help to solve this problem.,
    **************Code***************
    import java.util.*;
    public class NHLService {
      HashMap standings = new HashMap();
      public NHLService() {
        // NHL - part of the standings as per 04/07/2002
        standings.put("atlantic/philadelphia", "1");
        standings.put("atlantic/ny islanders", "2");
        standings.put("atlantic/new jersey", "3");
        standings.put("central/detroit", "1");
        standings.put("central/chicago", "2");
        standings.put("central/st.louis", "3");
      public String getCurrentPosition(String division, String team) {
        String p = (String)standings.get(division + '/' + team);
        return (p == null) ? "Team not found" : p;
    package hansen.playground;
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    import javax.xml.rpc.namespace.QName;
    import java.net.*;
    public class NHLServiceClient {
       public static void main(String [] args) throws Exception {
           Service service = new Service();
           Call call = (Call)service.createCall();
           String endpoint = "http://localhost:8081/axis/NHLService.jws";
           call.setTargetEndpointAddress(new URL(endpoint));
           call.setOperationName(new QName("getCurrentPosition"));
           String division = args[0];
           String team = args[1];
           String position =
             (String)call.invoke(new Object [] {new String(division), new String(team)});
           System.out.println("Got result : " + position);
    }************ classpath***************
    :/home/sujithkr/webservices/xml-axis/java:
    /home/sujithkr/webservices/xml-axis/webapps/axis/WEB-INF/lib/axis.jar
    /home/sujithkr/webservices/xml-axis/lib/activation.jar
    :/home/sujithkr/webservices/xml-axis/webapps/axis/WEB-INF/lib/clutil.jar
    :/home/sujithkr/webservices/xml-axis/webapps/axis/WEB-INF/lib/commons-logging.jar
    :/home/sujithkr/webservices/xml-axis/webapps/axis/WEB-INF/lib/jaxrpc.jar
    :/home/sujithkr/webservices/xml-axis/webapps/axis/WEB-INF/lib/log4j-core.jar
    :/home/sujithkr/webservices/xml-axis/webapps/axis/WEB-INF/lib/tt-bytecode.jar
    ********************Error Report*******************************
    java hansen.playground.NHLServiceClient atlantic philadelphia
    Exception in thread "main" Error while compiling: /usr/local/tomcat/webapps/axis//NHLService.java
    at org.apache.axis.message.SOAPFaultBuilder.endElement(Unknown Source)
    at org.apache.axis.encoding.DeserializationContextImpl.endElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
    at org.apache.axis.encoding.DeserializationContextImpl.parse(Unknown Source)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(Unknown Source)
    at org.apache.axis.client.Call.invoke(Unknown Source)
    at org.apache.axis.client.Call.invoke(Unknown Source)
    at org.apache.axis.client.Call.invoke(Unknown Source)
    at org.apache.axis.client.Call.invoke(Unknown Source)
    at hansen.playground.NHLServiceClient.main(NHLServiceClient.java:21)
    suse-1:/home/sujithkr/webservices # clear
    suse-1:/home/sujithkr/webservices # java hansen.playground.NHLServiceClient atlantic philadelphia
    Exception in thread "main" Error while compiling: /usr/local/tomcat/webapps/axis//NHLService.java
    at org.apache.axis.message.SOAPFaultBuilder.endElement(Unknown Source)
    at org.apache.axis.encoding.DeserializationContextImpl.endElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:633)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
    at org.apache.axis.encoding.DeserializationContextImpl.parse(Unknown Source)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(Unknown Source)
    at org.apache.axis.client.Call.invoke(Unknown Source)
    at org.apache.axis.client.Call.invoke(Unknown Source)
    at org.apache.axis.client.Call.invoke(Unknown Source)
    at org.apache.axis.client.Call.invoke(Unknown Source)
    at hansen.playground.NHLServiceClient.main(NHLServiceClient.java:21)
    thank you for helping me in your hectic schedule....

    Please post your code using code tags.
    When I try to compile or build i cant.What is your question? Exactly what error message do you get?

  • How can i run windows programs on my mac?

    i have a version of photoshop for windows, and i was wondering if it is possible to run that on my iMac. is there something i need to download?

    You have several options:
    1. Download and install Apple's Boot Camp which enables you to boot the computer either into Windows XP w/Service Pak 2 or OS X. This is a dual-boot solution.
    2. Purchase Parallels Desktop for Mac (www.parallels.com) which is virtualization software and enables you to run Windows (any version) simultaneously with OS X in a separate window.
    3. Purchase CodeWeavers' CrossOver (www.codeweavers.com) which enables you to run many Windows' applications without having to install Windows.
    All the above require you have an Intel Mac with at least 1 GB of installed RAM.
    Why reward points?(Quoted from Discussions Terms of Use.)
    The reward system helps to increase community participation. When a community member gives you (or another member) a reward for providing helpful advice or a solution to their question, your accumulated points will increase your status level within the community.
    Members may reward you with 5 points if they deem that your reply is helpful and 10 points if you post a solution to their issue. Likewise, when you mark a reply as Helpful or Solved in your own created topic, you will be awarding the respondent with the same point values.

  • How can i run a linux command in java app?

    i created a cell script to run the compile process of my C++ simulator and want to control it thru java application, i tried the following but it doesn't work.
    the command in linux should be. under the path /home/workspace/SIM/ run: . / zs_compile
    and i use runtime to do this
    String path="home/workspace/SIM/ . /zs_compile";
    try {Runtime.getRuntime().exec(path);}
    catch( IOException e) {
    e.printStackTrace() ;
    Error report is java.io.IOException: java.io.IOException: home/workspace/SIM/ . /zs_compile : not found
    who can help me to find the reason, thanks a lot!!!!!

    the reason is that the command you're truing to execute can't be found. se this article for other traps relatd to runtime.exec:
    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    the command in linux should be. under the path /home/workspace/SIM/ run: . / zs_compilecould yu elaborate a bit? "should be . under the path" -- do you mean it should be sourced from that path? Sourcing a script file makes no sense from a Java program.

  • How can I run a servlet with Sun Java System Application Server PE 8?

    I've created a package with a TestServlet.class inside, used the deploytool to create a WAR and deployed this using the autodeploy folder.
    The filestructure has been generated and I find the TestServlet.class in
    [installdir]\domains\domain1\applications\j2ee-modules\testProject\WEB-INF\classes\[packagefolderstructure]\TestServlet.class.
    The context root is working fine, but I have no clue how I can run the servlet directly via the URL.
    I've tried many things like
    http://localhost:8080/testProject/TestServlet
    http://localhost:8080/testProject/servlet/TestServlet
    http://localhost:8080/testProject/servlet/[packagenamewithpoints]TestServlet
    http://localhost:8080/testProject/servlet/[packagenamewithslashes]TestServlet
    etc etc
    Can somebody tell me please how to write URLs to deployed servlets? Or send me an example url and xml descriptor files?
    Thanks a lot in advance!

    in web.xml use servlet mapping
    <servlet-mapping>
        <servlet-name>TestServlet</servlet-name>
        <url-pattern>/doit</url-pattern>
    </servlet-mapping>then use http://localhost:8080/testProject/doit

  • How can I run a dos command from java on windows 98, 95?

    The usage of cmd.exe in the java program to run a dos command on windows 98. 95 doesn't work as the equivalent command is command.exe
    But using the command.exe in the java program makes my program to hang.

    hi,
    As u mentioned, u cannot use the cmd.exe in win9x environment as cmd.exe is specific to windows NT, you can use the command.exe without any hitches.
    for eg
    java.lang.Runtime.getRuntime().exec("start command /K a.bat"); should run the batch file a.bat..
    if the problem persists, try posting the snippet of code that you are using.
    cheerz
    ynkrish

  • How can i run my .class file with out installing java ?

    Hai friends..am new to java , plz help me any one.
    I wrote a small program in java lang. i want to run this program in my friend's system , which is doesnt have java language .. How can i run this program in my friends system with out installing java language?
    one of my friends told that ,it needs to copy the jvm in to ur directory where the java code is present . How can i copy the jvm from where to where ..?plz help me any one

    Your friend will have to install the Java runtime if they want to run Java
    programs.
    Don't go copying files yourself - and especially don't go copying them to the
    location of the Java code. After all, if your friend wants to run 42 different
    Java programs they shouldn't have to have 42 copies of the runtime.
    Just download and run the installer from this site:
    http://java.sun.com/javase/downloads/index.jsp
    Be careful to download the "Java Runtime Environment" not the JDK.

  • How can I start the program without the run button

    How can I start the program the instant i open the vi?
    without the use of Run.
    Thanks
    Solved!
    Go to Solution.

    Under vi properties, execution, click run when opened like in Jeff's screen capture below . Don't post any code set to run when opened to the forums!
    =====================
    LabVIEW 2012

  • In Lion, running on an i MAC (late 2006), how can I stop certain programs from automatically starting up when I start my MAC?

    In Lion, running on an I MAC, (late 2006), how can I stop certain programs (iTunes, Word) from automatically starting up when I start the computer?

    Any application that is open when you shut down will re-open when you restart unless you deselect this when shutting down/restarting:
    Also check System Preferences>Users & Groups>Login items tab and make sure there's nothing listed there that you don't want launched.

Maybe you are looking for

  • Not able to get complete data in Heading of the smarform

    Dear Friends,                 I am devloping a smartform for my requiremnt, i am not able to get complete data jin Header Window ( i.e the Title Name of the company is not getting fully) when i execute the Smartform , Iam able to see only the last fe

  • How to convert a pdf file into RTF format or Doc Format

    Hello I need to convert a pdf file into a rtf file or doc file. But i need to do this with a command line or with the api of acrobat. My version is adobe acrobat 9 standard. Is it possible to do this? So i see there's a convert pdf online. Is it poss

  • Hp laptop won't turn on at all.

    I have no idea what model it is. Where do I find this in the machine. The laptop won't turn on. I have changed the fuse in the plug but the wires are not getting warm. I have no idea. When the battery is in and I try to turn it on the orange light fl

  • PDF and video links

    I just upgraded to RoboHelp 7 so I could fix the active x popup issue when running program by selecting Add Mark of the Web checkbox. But now my links to pdf files and video don't work inless you save first. How can I fix this issue? Thanks in advanc

  • Timestamp query in partitioned table - can this work?

    Hi, I have a table RANGE partitioned by a column named: CREATE_DATE (DATE). Its purpose is to manage the daily create/drop partitions of this table, I do not want to include this column in queries. I do not have an index on this column. We chose DATE