Starting Cobol program from JAVA

Hi
For a school project we have to do a part Java & a part cobol
The COBOL programmes are all to read CSV files into an MS access DB
Well as a challenge we have to make a buton in the GUI of our JAVA program that starts 1 of these COBOL programes when clicked
The java program was written/modelled in Together Architect 2006 (eclipse plugin, sry the school forces us to use it) and the COBOL were/are written in percobol from legacyJ
txn for any help

i've done that but i seem to not getting the hang of
it
from what i get is it something like thhis
runetime.getRuntime().exec("myCobolprog.cbl");
yet it doesnt seem to work
or i just get errors in the IORead this first:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

Similar Messages

  • Running COBOL programs from java

    I am on a project at the moment where we want the client-server to be written in Java on Solaris Sparc UNIX machines. The thing is we want the server to start a COBOL program and the output from the COBOL program will be the reply to the client. Is this possible and if so how?
    Any help gratefully received
    Chris
    PS We are not looking to buy expensive tools

    JNI would be necesssary if you want to call cobol routines from your java program or vice versa. If you want to communicate with another process then JNI is not really necessary. Indeed it is a very difficult API to master and unnecessary complexity. Well the way I was thinking was that your cobol program can accept input from standard input and write to standard output (if there is such a thing in cobol). You can then read the inputstream of the process which you spawned using runtime.getRuntime.exec("mycobolprogram) mechanism...This should work fairly realiably. I am not sure if this is what you are looking for but give it a try by writing a small cobol program which outputs "Hello World" to standard output and then try reading it from a test java program...

  • Starting a external program from java

    hi iam trying to start MySQL server from java, the command in dos is as follows C:\mysql\bin\mysql -u username -p ,then the user hits return and the user is prompted to enter a password. i have got as far as entering the the C:\mysql\bin\mysql -u username -p but dont know how get the prompt back to the java program i would be greatfull if anyone could tell me where iam not doing,heres my code so far
    try{
    Runtime r=null;
    r=r.getRuntime();
    Process p=r.exec("C:/mysql/bin/mysql -u mark_r -p");
    p.waitFor();}
    catch(Exception ex){System.out.print("Error");}}

    You should try using the getOutputStream() and getInputStream() methods for the Process object. Each returns either an inputStream or OutputStream object.
    You should be careful if the mySQL password is added to the command since anyone doing a 'ps' on the machine could see the password.

  • Starting a program from the shell into a vncserver running on 5901

    I started a vncserver via `vncserver -geometry 1792x1008 -alwaysshared :1` and within it, I am running xfce4 just fine.  I would like to start a program from a shell outside of the vncserver.  I tried the following but got errors.  What am I missing?
    % DISPLAY=1.0 lxterminal
    (lxterminal:17489): Gtk-WARNING **: cannot open display: 1.0

    Try
    $ export DISPLAY=:1
    $ lxterminal
    That works over here.
    Last edited by mwillems (2015-04-21 00:03:43)

  • How do I call a C++ program from Java?

    I've tried using Runtime.exec to call my C++ program from Java but I don't think I'm doing it correctly. Could someone explain how to properly use it? Here's what I'm trying (this is in an applet that is only going to be running on an intranet so only PCs in my LAN will be affected):
    Runtime runtime=runtime.getRuntime();
    Process proc =runtime.exec("mkdir C:\\Test");

    What do you expect your operating system should do with a command "mkdir"? It doesn't understand this. "mkdir" is a shell command, so you need to execute the shell:
    runtime.exec("cmd /c mkdir C:\\test");

  • How to Call abap functn/program from java layer

    Hi all,
        I have to develop a program which has to call abap function/program from java side or how to call a abap program through java ..
    pls send me related links or explanations.. dont send unrelated answers..
    Regards,
    Arivarasu S

    Hi,
    You mean accessing ABAP functions from J2EE perspective, then I think we can do this by using SAP Java Resource Adapter and also through webservices.
    SAP Java Resource Adapter (SAP JRA) can be used as an add-on for the SAP JCo SAP JRA enables the implementation of standard interfaces from diverse J2EE servers to the SAP JCo in the SAP Web AS. The SAP JRA thus simplifies
    communication with ABAP within heterogeneous J2EE landscapes.
    Go through the following links which has Good documentation on how to achieve this
    Accessing BAPIs Using the SAP Java Resource Adapter
    [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/ad09cd07-0a01-0010-93a9-933e247d3ba4]
    Connectivity and Interoperability
    [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/326d82e5-0601-0010-fca4-9caf27b89c26]
    Finally with WebServices. Accessing SAP Business Functions (ABAP) via Web Services
    [https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/06adbf03-0a01-0010-f386-d8e45561a3c4]
    Regards
    Raghu

  • Can we run EXE file/ Another Java Program from Java Application? How?

    Can we run EXE file and another java program from java application?
    Thanks in advance

    Example running adobe acrobat
    String command = "C:\\Program Files\\Adobe\\Acrobat 5.0\\Reader\\AcroRd32.exe /t "+selectedDocument+" \\\\CONTROL\\HP LaserJet 4L";
    Runtime rn = Runtime.getRuntime();
    Process process = rn.exec(command);
    process.waitFor();rykk

  • Error in calling 'C'  Program from Java

    Hi,
    We developed a 'C' Program and during compilation, we got a couple of Incompatible Prototype warnings. Then we made a Jni call to 'C' program from Java Program. The program returned a "Unsatisfied Link Error - unreference Symbol not found" error.
    Does Jni call fails owing to warnings by compiler?
    We are using Sun Solaris 2.8.
    Request your assistance as this a urgent issue.
    Thanks
    Srini

    Did you try running your C program through g++? It sounds like something is broken, but GCC often will allow you to compile anyways.
    -Jason Thomas.

  • Start JavaFX application from Java

    Hello,
    I have the following scenario:
    I have a small JavaFX application and a big Java application. Now the Java App should call the JavaFX App to start up.
    Further the JavaFX App has to call some methods from the Java App. Is this possible?
    What is the best approach for my scenario?
    Maybe somebody has made some experiences ..
    thanks!
    Edited by: 799878 on 03.11.2010 07:54

    "Now the Java App should call the JavaFX App to start up."
    I'm assuming that the JavaFX code and the Java code are in the same application, correct? If so, then there are hacks available, but no standard way to start up JavaFX from Java will exist until the APIs have been ported from JavaFX script to Java.
    "Further the JavaFX App has to call some methods from the Java App. Is this possible?"
    Yes. Java can be called from JavaFX just fine. Just be careful if you use multi-threading or time consuming operations, since JavaFX script is apparently single threaded. Also be aware that netbeans normally compiles JavaFX applications with JSE version 1.5, so library features that did not exist until later versions will not be available by default.

  • Call visual prolog program from java

    Hi friends,
    is there someone help me to call ( run) prolog program from java.
    i write a parser with Javacc parser generator and stored parsed information in prolog database and I want create some query in java that work in the prolog file.
    how can i combine java and prolog programs. i used visual prolog.
    Can someone help me?
    Thanks you in advance.
    yours sincerely,
    ksu

    Since visual prolog can produce dll's, you can use JNI:
    http://java.sun.com/j2se/1.4.2/docs/guide/jni/index.html

  • Start up a program from Java

    Hi,
    How could I start an executable from within my Java application?
    Something like:
    public void start_converter(String toFormat){
    String newFormat = toFormat;
    if newFormat.equalsIgnoreCase("MIF"){
    //call the MapInfo program
    System.startup("MapBasic/convertToMIF.mbx"); // .startup is just a dumb guess. Are there any possibilities to do this in some way?
    Thanks,
    Anders

    take a look at Runtime.getRuntime().exec(...) in the API

  • Starting weblogic server from java program

    Runtime r=Runtime.getRuntime();
    Process p=r.exec("cmd /c d:/bea/weblogic700/server/bin/setWLSEnv.cmd");
    when ihave given like this it is working.
    now i want to start weblogicserver from jav program
    String s="-Dweblogic.Domain=mydomain weblogic.Server"
    Process p=r.exec("cmd /c d:/bea/weblogic700/server/bin/setWLSEnv.cmd java "+s);
    when i gave like this weblogicserver should start with specified domain
    but no output is comming.please tellme where the problem is

    no - nothing happened. it perform the next java code - and there is nothing else happen on the windows.
    maybe i don't check in the right place for the error you are talking about?
    i also tried i simple cmd file that does nothing - but still nothing...
    for any other file types it works properly.

  • Calling Cobol program from PL/SQL

    What is the caling convention for PL/SQL to call a Cobol program?

    You cannot do it directly from PL/SQL. PL/SQL is.. well, kind of abstract ito the actual platform it runs on. PL/SQL cannot talk directly to operating system. It cannot (itself) do socket calls, file I/O calls, use the printer, etc.
    <p>
    All this has to be done using a lower level implementation library - like UTL_FILE for example that wraps internal C written modules that does file I/O. PL/SQL can call these to do I/O on its behalf. Ditto for wrappers like UTL_TCP and others.
    <p>
    There is no default wrapper for calling external processes from PL/SQL. It can however be done indirectly using the external procedure (EXTPROC) feature, or using Java to do it.
    <p>
    The latter is the easiest. You create a Java stored proc that can access the operating system and run external programs and commands. You punch a big hole in the Oracle Java security to allow this Java stored proc access to the operating system. Next you create a PL/SQL wrapper for this Java proc which then in turn can be called from PL/SQL.
    Just remember that you MUST secure this hole you've punched into Oracle security. If any Oracle user can access this PL/SQL wrapper, they can hack, compromise, trash or simply destroy your entire Oracle account on that server.
    Here is the basic code:
    create or replace and compile Java Source named "OSCommand" as
    -- java:        OS COMMAND
    -- descr:       Executes an Operating System Command using the JAVA RTS
    -- IN parameter:        os command to execute (including fully qualified path names)
    -- OUT parameter:       returncode [\nstring]
    --                      where string a max of 32000 chars of the output of the command
    --                      (note that \n is used as separators in the string)
    --                      returncode=-1   Java RTS error occurred (e.g. command does not exist)
    --                      returncode=255  o/s command failed (e.g. invalid command params)
    import java.io.*;
    import java.lang.*;
    public class OSCommand{
            public static String Run(String Command){
                    Runtime rt = Runtime.getRuntime();
                    int     rc = -1;
                    try{
                            Process p = rt.exec( Command );
                            int bufSize = 32000;
                            int len = 0;
                            byte buffer[] = new byte[bufSize];
                            String s = null;
                            BufferedInputStream bis = new BufferedInputStream( p.getInputStream(), bufSize );
                            len = bis.read( buffer, 0, bufSize );
                            rc = p.waitFor();
                            if ( len != -1 ){
                                    s = new String( buffer, 0, len );
                                    return( s );
                            return( rc+"" );
                    catch (Exception e){
                            e.printStackTrace();
                            return(  "-1\ncommand[" + Command + "]\n" + e.getMessage() );
    show errors
    create or replace function OSexec( cCommand IN string ) return varchar2 is
    -- function:    OS EXEC
    -- descr:       PL/SQL wrapper for the Java OSCOMMAND stored proc
    language        JAVA
    name            'OSCommand.Run(java.lang.String) return java.lang.String';
    show errors
    -- Punching a hole into the Java VM sandbox. The following must be run as
    -- sysdba. Substitute SCOTT with the applicable schema that owns the OSEXEC
    -- and OSCOMMAND stored procs.
    declare
            SCHEMA  varchar2(30) := 'SCOTT';
    begin
            dbms_java.grant_permission(
                    SCHEMA,
                    'SYS:java.io.FilePermission',
                    '<<ALL FILES>>',
                    'execute'
            dbms_java.grant_permission(
                    SCHEMA,
                    'SYS:java.lang.RuntimePermission',
                    'writeFileDescriptor',
            dbms_java.grant_permission(
                    SCHEMA,
                    'SYS:java.lang.RuntimePermission',
                    'readFileDescriptor',
    commit;
    end;
    -- example: running the Unix/Linux date command to get the current date and time
    SQL> select OSexec('/usr/bin/date') as STDOUT from dual;
    STDOUT
    Fri Sep  1 08:09:34 SAST 2006
    1 row selected.
    SQL>Edited by: Billy Verreynne on Sep 4, 2008 6:26 PM to make the code snippet readable with the new Jive forum s/w.

  • Problems running external Win32 Multithread C-Program from Java

    hi,
    i just wrote a little java application which is calling my c-binary (a win32 multithread application written in pure ansi c) . let's call it "test.exe". i'm launching it via:
    Runtime.getRuntime().exec(cmd, new String[] { env }, dir)the program is started correctly and i get all test.exe outputs on my java console (therefor i grabbed the inputstream and errorstream of the process-object ...). so far so good.
    my problem is, that something with the multithreading seems to be wrong, when launching my test.exe from java!
    for example, i have the following line of code in my c-program (test.exe):
    WaitForSingleObject( g_hMutexREADY, INFINITE );if i launch my program as java process, this line seems to be ignored! that means, the program doesn't stop executing at this point (and is waiting for the mutex) but simply continues executing, causing the whole program to crash.
    if i run the same program directly from the winxp commandline all is working fine (that means: the threads of 'test.exe' synchronize each other correctly via the mutexes)!
    does anybody has an idea or have already had similar problems? maybe some win32 libraries are missing, could that be?
    thanks a lot.
    k4simir

    I just debugged a little bit through my c program. and it's not the multithrading stuff causing the error, but the win32 socket creation!
    my "multithreading c program" :-) is an ASR (automatic speech recognizer). it runs as socket server (on localhost) and accepts connections from clients (my java application). the client (java app) controls the ASR server (means start(), stop(), open(), close() ...). if the ASR server recognizes some user input, it will transfer it to the client for further processing.
    so far the theory. if i launch the ASR server via the window command line, the communication and the other stuff works fine. now i want my java app to launch the ASR server.
    the ASR fails, when it tries to create the socket:
    g_Vars.kServSock = socket( AF_INET, SOCK_STREAM, 0 );the error code returned by WSAGetLastError() is 10106! i didn't find this error code in the msdn! so i don't know what it means or what might be the problem.
    any ideas?
    thanks a lot!
    k4simir
    here's the full code:
    int     InitSocket( short sPortNr ) {
         int               iErr;
         SOCKADDR_IN     kMyAddr;
         iErr = StartUp();
         if( iErr != _SRC_OK ) {
              return _SRC_ERROR;
         // create server-socket:
         g_Vars.kServSock = socket( AF_INET, SOCK_STREAM, 0 );
         if( g_Vars.kServSock == INVALID_SOCKET ) {
              CleanUp();
              return _SRC_ERROR;
    int StartUp() {
         WORD wVersionRequested;
         WSADATA wsaData;
         int err;
         _DEBUGPRINT
         wVersionRequested = MAKEWORD( 2, 2 );
         err = WSAStartup( wVersionRequested, &wsaData );
         if ( err != 0 ) {
              return _SRC_ERROR;
         if ( LOBYTE( wsaData.wVersion ) != 2 ||
               HIBYTE( wsaData.wVersion ) != 2 ) {
              WSACleanup( );
              return _SRC_ERROR;
         return _SRC_OK;
    }

  • Cannot run batch program from Java Application

    Hi All,
    Im trying to run a batch file under windows from my Java Program. The batch file is located in the following path:
    C:\Program Files\MyApp\runme.bat
    The above-entioned path contains white space which is not allowed in NT.
    Im trying following code:
    import java.io.*;
    public class Exec {
    public static void main(String args) {
    try {
    Runtime.getRuntime().exec("cmd /c start C:/Program Files/MyApp/runme.bat");
    }catch(Exception ex){ ex.printStackTrace();}
    How to run this file?
    Thanks in advance.
    Ketan Malekar

    or use the overload that takes an array of strings as argument
    String[] command = {"cmd", "/c", "start", "C:/Program Files/MyApp/runme.bat");
    Runtime.getRuntime().exec(command);

Maybe you are looking for

  • Why is preview different than once it is rendered !!!!

    Man, i hope you guys can help me with this fustrating problem. I finished a project in 8 bit uncompressed. There's a particular spot where i'm compositing 2 video and one of them has a flare FX. In the unlimited preview mode it looks fine but once i

  • Product code for acrobat X pro is not recognized.  how to activate

    HELP!!!!  I have the teacher/student edition for acrobat X.  I originally downloaded to desktop.  However, I now use laptop.  Since it has no drive, I downloaded the 30 day trial.  I have the serial number/activation code....but it is not recognized.

  • ORA-19510: failed to set size with ORA-27059: could not reduce file size

    Hi, I have RMAN backup implemented and getting below error. RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: ==================================

  • My Macbook Pro is crashing frequently

    I cannot pinpoint exactly what triggered this, I suspect it was after I upgraded to Mavericks, but my early 2011 MBP 15' has been very slow to start and crashes very frequently, without apparent reason. This is the last crash error report. Anyone has

  • Using Virtual InfoProvider with DBConnect

    Hi all, I'd want to use a virtual InfoProvider in order to acces Teradata database live.  Can I use DBConnect?  I know that it is possible to use UDC with the version 3.5.  But in my case, we have the version 3.0.x.  Is there somedy that can help me