How to run a makefile from java app?

Hi,
I want to run a make command the first time my java swing application is run. The makefile is in a directory that the application is using for input files. Do I need to write a script to house the make command or is there another way to run make?
Thanks

Thanks for that but I'm not actually trying to build a makefile for my java app - I just want to be able to run one that is going to generate a bunch of html files for my application to access. The make command works great from the command line but I can't just put a directory followed by "make html" in a string and run it using runtime.exec in my application.

Similar Messages

  • How to execute Linux command from Java app.

    Hi all,
    Could anyone show me how to execute Linux command from Java app. For example, I have the need to execute the "ls" command from my Java app (which is running on the Linux machine), how should I write the codes?
    Thanks a lot,

    You can use "built-in" shell commands, you just need to invoke the shell and tell it to run the command. See the -c switch in the man page for your shell. But, "ls" isn't built-in anyays.
    If you use exec, you will want to set the directory with the dir argument to exec, or add it to the command or cmdarray. See the API for the variants of java.lang.Runtime.exec(). (If you're invoking it repeatedly, you can most likely modify a cmdarray more efficiently than having exec() decompose your command).
    You will also definitely want to save the returned Process and read the output from it (possibly stderr too and get an exit status). See API for java.lang.Process. Here's an example
    java.io.BufferedReader br =
    new java.io.BufferedReader(new java.io.InputStreamReader(
    Runtime.getRuntime().exec ("/sbin/ifconfig ppp0").
    getInputStream()));
    while ((s = br.readLine()) != null) {...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to connect to mysql from java app

    hi
    please say the procedure for connecting to mysql database from java app.
    .) what should i give in environmental variables
    .)where can i find the driver class for the mysql
    .) syntax of the url
    eg:- DM.getConnection("jdbc:mysql:..............what comes here..............");

    You can also get connections from a DataSource. Simple example:
                MysqlDataSource msds = new MysqlDataSource();
                msds.setUrl("jdbc:mysql://127.0.0.1:3306/dbdame");
                msds.setUser("user");
                msds.setPassword("pass");
                Connection c = msds.getConnection();Explore your options and be sure to consider connection pooling.

  • How to run ODI scenario from java?

    I am new to java, need to do some testing on how to invoke ODI scenarios from java.
    Can somebody drop me some simple code?
    Thanks a lot,
    Lei

    Hi there
    1. Start your agent (double click agent.bat)
    2. generate scenario for ur package(right click ur package , select generate scenario)
    3. Add the odi-sdk-invocation.jar file to your java project
    ODIcmdScenario=new OdiCommandScenario();
    ODIConnection=new OdiRepositoryConnection();
    ODIConnection.setOdiUser("ur-username");
    ODIConnection.setOdiPassword("ur-password");
    ODIConnection.setJdbcDriver("Driverdetail");
    ODIConnection.setJdbcUrl("url-details");
    ODIConnection.setJdbcUser("dbusername");
    ODIConnection.setJdbcPassword("dbpass");
    ODIcmdScenario.setScenName("scenarioname");
    ODIcmdScenario.setScenVersion("scenarioversion");
    ODIcmdScenario.setLogLevel(5);
    ODIcmdScenario.setContext("context");
    ODIConnection.setWorkRepositoryCode("repository");
    ODIInvocation = new OdiInvocation("hostname", 20910); //20910 default port
    OdiInvocationResult result=ODIInvocation.invokeCommand(ODIcmdScenario,ODIConnection);
    Hope this helps!
    Cheers

  • How to run SQL files from Java?

    Hi,
    Can someone point me towards a link on how to run sql files in Java? Thanks.
    P.S...if I've been completely blind please go easy on me!

    Sorry forgot the formating code thingy
    public static boolean executeScript(File script, Connection conn){
        boolean success = true;
        success = script.exists();
        if(success){
          DEBUG.print("ES::READING SCRIPT:" + script.getAbsolutePath());
          StringBuffer buffer = new StringBuffer();
          success=readScript(script,buffer);
          if(success){
            try{
              String creationScript = buffer.toString();
              Statement st = conn.createStatement();
              int start = 0;
              int end = 0;
              while (end != -1 && start < creationScript.length()) {
                end = creationScript.indexOf("GO", start);
                if (end != -1) {
                  DEBUG.print(creationScript.substring(start, end));
                  st.executeUpdate(creationScript.substring(start, end));
                  start = end + 2; //2 is the length of "GO"
              st.close();
            }catch(Exception e){
              success=false;
              DEBUG.printStackTrace(e);
        }else{
          DEBUG.print("ES::SCRIPT FILE DOES NOT EXISTS");
          success=false;
        return success;
      public static boolean readScript(File script, StringBuffer buffer){
        boolean success = true;
        DEBUG.print("RS:: reading file :" + script.getAbsolutePath());
        try{
          InputStreamReader isr = new InputStreamReader(new FileInputStream(script),"UTF16");
          int ch;
          while ( (ch = isr.read()) > -1) {
            buffer.append( (char) ch);
          if (isr != null)
            isr.close();
        }catch(Exception e){
          success=false;
          DEBUG.printStackTrace(e);
        return success;
      }

  • How to run .html file from .java file..?

    Hi All,
    I was just trying as mentioned in the subject of how to run an html file from a java file.We have runtime class which inturn is having exec method which returns process but it supports only .exe as an argument .Is there any way to do this???
    Thanks in advance.

    viswa07 wrote:
    You mean to say Desktop class in java...???I'm so sorry, I thought you knew enough Java to look up the API.
    [This link|http://java.sun.com/docs/books/tutorial/getStarted/cupojava/index.html] might be more at your level.
    db

  • How to run a vi from Java application?

    I am passing data to a vi from my java swing application using data socket bean but I have to manually open and run the vi. How can I programatically open and run the vi from my java application without using ActiveX automation server?

    I don't know Java but if you can issue a shell command then you can run the VI with the command line:
    "\labview.exe" ""
    You have to set the VI to "Run when opened". The VI will run each time the command is issued, even if the VI is already opened.
    LabVIEW, C'est LabVIEW

  • How to run system commands from JAVA

    Hi Friends,
    How to run windows system commands from JAVA
    Runtime r=Runtime.getRuntime();
    r.exec("dir");
    Throwing following Exception
    CreateProcess :dir error=2
    Thanks in advance
    Hamsa

    Hi ,
    in Windows NT this is not possible, you can use the following :
    Runtime r=Runtime.getRuntime();
    StringBuffer sbuf = new StringBuffer();
    String dir = new String();
    java.lang.Process proc = r.exec("cmd /c dir");
    InputStream is = proc.getInputStream();
    int ch ;
    while((ch=is.read() ) != -1)
    sbuf.append((char)ch);
    is.close();
    dir = sbuf.toString();
    System.out.println(dir );

  • Running PHP script from Java apps

    Hi,
    I have a PHP application that opens up a template (MS Word) invoice file, inserts some information in the file (eg. today's date, customer name) and then saves it as a new Word file. My questions are as follows.
    1- How can I call this script from my Java application. Please not that I want to be able to pass parameters (eg. custome name read from a DB) from my Java app. to this script.
    2- Is it possible to print already saved MS Word documents from Java? If so, how?
    3- Is it possible to do what my PHP script is doing in pure Java? I couldn't find a simple way of doing this, that's why I used PHP but I would like to do this in Java if I can.
    thanks in advance,
    Mete

    Don't reply here. Go here instead.
    http://forum.java.sun.com/thread.jsp?forum=54&thread=479160&tstart=0&trange=15
    Cross-listed
    Sorry, I thought this didn't post before.

  • How to run Other application from Java

    I want to run other applications such as IE.exe, notepad.exe from Java? How can I run?

    Dear Friend, the following is the code to open IExplorer from Java Program
    class RunTimeTest {
    public static void main(String args[]) {
    try {
    Runtime.getRuntime().exec("C:\\Program Files\\Internet Explorer\\IEXPLORE.exe");
    catch(Exception e) {
    [\code]
    ALL THE BEST
    Shiva                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to run perl file from java file..???

    Hi All,
    How to run a perl file from java file.I know that there is one JPL(Java-Perl Library) preprocessor which can be used to do this,but no idea of how to do it..
    Any help is appreciated.
    Thanks in advance.

    viswa07 wrote:
    Ok and any idea regarding JPL..????I don't know it and the first few posts that I found mentioned it using Java 1.1-style JNI calls, which hints at a dead project. And you don't want to use a dead project.

  • How to run geniatagger.exe from java

    Hi,
    i'm trying to run geniatagger-1.0.exe from java on windows vista, using Process pr = Runtime.getRuntime().exec("C:/geniatagger-1.0/geniatagger-1.0.exe");
    However, i keep on getting the same error. "Cannot run *.exe CreateProcess error=2" . I tried the same code with excel.exe which is installed in C:/ProgramFiles
    and it worked. I also tried to create a path variable C:/geniatagger-1.0/geniatagger.exe;%path% and then run the same java code. Yet, nothing has changed.
    I would really apreciate any help

    dalab wrote:
    Sorry, i didn't realise that the link was already sent! I found that earlier as well. I"I..." what?
    "I ...figured it out"?
    "I ... still need help"?
    You're not a vampire named Trever are you?

  • How to run another concurrent from Java Concurrent Program?

    Hi,
    I have one Java Concurrent Program in ebs R12.
    I need to run another Java Concurrent Program when first finished.
    I can not find a way to start another request from JCP.
    Thanks,
    ms

    Hi ,
    this is an example code to check the OS before running the command :
    try{
    int ch;
    Process proc ;
    Runtime r=Runtime.getRuntime();
    StringBuffer sbuf = new StringBuffer();
    String dir = new String();
    String osname = System.getProperty("os.name");
    if(osname.equals("Windows NT") )
    proc = r.exec("cmd /c dir");
    if(osname.startsWith("Linux") )
    proc = r.exec("df -k");
    InputStream is = proc.getInputStream();
    while((ch=is.read() ) != -1)
    sbuf.append((char)ch);
    is.close();
    dir = sbuf.toString();
    System.out.println(dir );
    }catch(Exception e){ System.out.println(e.getMessage());}
    bye
    Taha

  • How to run native program with Java program?

    Hello
    I've got following problem. I'd like to write file browser which would work for Linux and
    Windows. Most of this program would be independent of the system but running programs not. How to run Linux program from Java program (or applet) and how to do it in Windows?.
    Cheers

    Try this:
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec("ls -l");
    InputStream stream = proc.getInputStream();
    InputStreamReader isr = new InputStreamReader(stream);
    BufferedReader br = new BufferedReader(isr);
    String line = null;
    while ( (line = br.readLine()) != null) .....
    "if the program you launch produces output or expects input, ensure that you process the input and output streams" (http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html)

  • Help! How to convert an instance from java.lang.Object to a particula class

    * How to convert an instance from java.lang.Object class to a particular class
    witch is known only at the running time?
    Roster EJB component is make up of RosterHome, Roster and RosterBean.
    RosterHome is the home interface of Roster EJB.
    Roster is the remote interface of Roster EJB.
    RosterBean is the implement of Roster EJB.
    The following code segment is to invoke Roster EJB component.
    String jndiName="roster.RosterHome";
    javax.naming.Context initial = getInitialContext();//getInitialContext() returns a instance of Context.
    Object objref = initial.lookup(jndiName);
    RosterHome home =
    (RosterHome)javax.rmi.PortableRemoteObject.narrow(objref,
    RosterHome.class);
    Roster myRoster = home.create();
    String team="T1"
    String player="Tom"
    myRoster.addPlayer(player,team);
    But, now, all the home interface, the remote interface and the JNDI Name of
    Roster EJB component are not been known at the compiling time. However They are
    known at the running time, throught reading from the XML config file.
    Questions:
    1,How to write code for this case ? or
    2,How to convert an instance from Object class to a particular class witch is known
    only at the running time?
    String jndiName="roster.RosterHome";// in fact, reads from XML file.
    String homeClassName="roster.RosterHome";// in fact, reads from XML file.
    String remoteClassName="roster.Roster";// in fact, reads from XML file.
    javax.naming.Context initial = getInitialContext();//getInitialContext() returns a instance of Context.
    Object objref = initial.lookup(jndiName);
    Object objHome= javax.rmi.PortableRemoteObject.narrow(objref,
    Class.forName(homeClassName));
    /* how to do next?
    }

    I am not sure what you are trying to do. But at some point you should know which methods to call on the remote interfaces. Maybe the method names are stored in the XML file as well or you have a set of standard method names (also consider parameters).
    However, this can be solved by reflection. Look at the java.lang.reflect package, especially java.lang.reflect.Method, and also at java.lang.Class.
    If you are doing this on the app server:
    I've seen posts where people say that reflection is not permitted in EJB, but I don't think so. Check the EJB spec.
    If you are doing this in an application: reflection is always permitted. Probably also in applets and JSP.

Maybe you are looking for

  • Display image in datagrid column

    I have a datagrid with a column that displays true or false if an item "has children" or not. How would I go about placing an image in the column depending on the value of the column. I want to have two different images one for false and one for true

  • Session TimeOuts

    Hi again, Thanks for the response on my application model question. Here's another one : Is there a way to set a timeout on a query to a DBMS using the DBSession (or some other way) ? Or must I rely on a timeout setting in the DBMS ? Thanks. Christia

  • Upgrade to Acrobat 9 pro from previous upgrades

    Is it possible to upgrade from 2 previous upgrades from 5.0 standard? I am using 7 pro upgrade, from 6 standard upgrade, from 5 standard

  • Podcast cover looks fine in app, won't update in store?

    Hi all, I have been lurking on this forum for a while, and I'm sorry to say I have yet another podcast cover issue to throw on the pile! Background: I created a podcast last summer. At first, the cover image I submitted was a bit of a placeholder. A

  • I can not open some apps

    Hello, I am having trouble with opening some apps.  I haven't been able to open them for a couple days.