Executing java from unix shell script

Hi, I am trying to execute java program from a unix shell script and the program has a command line parameter. I have tried in ways like
/opt/java1.4/bin/java CollExtractLoadProcess /home/inbox/archive/file_name
/opt/java1.4/bin/java CollExtractLoadProcess "/home/inbox/archive/file_name"
/opt/java1.4/bin/java CollExtractLoadProcess '/home/inbox/archive/file_name'
/opt/java1.4/bin/java CollExtractLoadProcess file_name
No matter how I execute it gives me the following error
Exception in thread "main" java.lang.ClassFormatError: CollExtractLoadProcess (C
ode segment has wrong length)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
3)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
Could someone please let me know what is the correct way of doing this?
Thanks.

Sounds like you either have a corrupt class file or you're using an older version of the JVM to try to execute classe that were compiled for a newer version.

Similar Messages

  • Calling stored procedure from unix shell script

    Hello,
    I am facing a problem while calling a stored procedure from UNIX shell script. I want to return a output variable from the stored procedure to the UNIX environment.
    Here is the code-
    #!/bin/sh
    OUTPUT=`sqlplus cmag/magnum@dw <<ENDOFSQL
    set serveroutput on;
    var prd_out varchar2(100);
    exec create_pm_window(:prd_out);
    exit;
    ENDOFSQL`
    echo " output is - $OUTPUT"
    The problem is :prd_out is not getting copied to shell variable OUTPUT.
    I have a dbms_output.put_line in the stored proc create_pm_window and I can see that prd_out is getting populated.
    Any help is really appreciated.
    Thanks'
    Rakhee

    First step :
    make sure the PL/SQL works as expected.
    Does the following display the expected output executed from SQL*Plus ?
    set serverout on
    declare
    prd_out varchar2(100);
    begin
    create_pm_window(prd_out);
    dbms_output.put_line('output is '||prd_out);
    end;
    I don't have your procedure, but using a dummy procedure like :
    Scott@my10g SQL>create procedure foo(p_out in out varchar2)   
      2  is
      3  begin
      4  select 'Hello '||instance_name into p_out from v$instance;
      5  end;
      6  /
    Procedure created. and a toto.sh script as :OUTPUT=`sqlplus -s scott/tiger <<EOF
    set pages 0 lines 120 trimout on trimspool on tab off echo off verify off feed off serverout on
    var mavar varchar2(100);
    exec foo(:mavar);
    print mavar;
    exit;
    EOF`
    echo "OUT = ${OUTPUT}"
    exitIt works fine :[oracle@Nicosa-oel ~]$ ./toto.sh
    OUT = Hello my10g

  • Return codes from sqlldr command from unix shell script

    I am trying to capture error code from sql loader from unix shell script and display proper messages.
    sqlldr parfile=sdb.par control=$cntlfile data=$infile bad=$badFile log=$logFile rows=10000
    rows=10000
    retcode=`echo $?`
    case "$retcode" in
    0) echo "SQL*Loader execution successful" ;;
    1) echo "SQL*Loader execution exited with EX_FAIL, see logfile" ;;
    2) echo "SQL*Loader execution exited with EX_WARN, see logfile" ;;
    3) echo "SQL*Loader execution encountered a fatal error" ;;
    *) echo "unknown return code";;
    esac
    Eventhough, there are errors while executing sqlldr, it is always returing recode zero. What could be the possible reason
    Please advice

    Is there a typo in your code ?
    sqlldr parfile=sdb.par control=$cntlfile data=$infile bad=$badFile log=$logFile rows=10000
    rows=10000
    retcode=`echo $?` In this code, you get the return code of the statement in bold which is not the sqlldr statement ...

  • Calling a report from unix shell script

    Hi,
    I had to call a report from unix shell script.
    May i know the procedure to accomplish this
    Thanks in Advance
    A.Gopal

    First you should not include the whole path to your report in the call ...
    Use like this:
    /ora/u01/oracle/v101/as2/bin/rwrun.sh report=an_stati destype=file desname=/ora/u01/oracle/v101/as2/test.pdf desformat=pdf
    In $ORACLE_HOME/bin/reports.sh:
    1) Verify that you have updated the REPORTS_PATH variable to include your folder where you have the report in question
    REPORTS_PATH=/ora/u20/app/qits/env1/run:$ORACLE_HOME/reports/templates:$ORACLE_HOME/reports/samples/demo: ....
    2) Verify that the REPORTS_TMP variable is pointing to a valid location and that the oracle user has access to write on it.
    After that, post the content of the tracefile located at $ORACLE_HOME/reports/logs/{in-process report server name folder}/rwserver.trc
    If no file is present then it means that you need to enable trace in your reports's conf file.... go to the $ORACLE_HOME/reports/conf folder and and locate the .conf file that correspond to your in-process reports server name (as specified in the rwservelet.properties file)... open/edit the file to enable trace logs ..
    i.e.
    Change the following line:
    <!--trace traceOpts="trace_all"/-->
    to <trace traceOpts="trace_all"/>
    Bounce the reports server and try to run the report again, this time the .trc file should be generated, post the content so that we can take a look.

  • Execute stored procedure from Unix shell script

    My current method of executing stored procedures (wpl_1 and wpl_2) from a unix shell script is as follows:
    <<wpl.sh>>
    sqlplus user/password @/home/oracle/scripts/wpl.sql
    <<wpl.sql>>
    set serveroutput on size 1000000
    set timing on
    execute wpl_1('0000010676','~')
    execute wpl_2('0000010676','~')
    execute wpl_1('0000010236','FIX')
    execute wpl_2('0000010236','FIX')
    exit
    Question: Is it possible to combine the two scripts (unix and oracle) together?

    A little rusty on this, but this may work:
    My current method of executing stored procedures
    (wpl_1 and wpl_2) from a unix shell script is as
    follows:
    <<wpl.sh>>sqlplus user/password @/home/oracle/scripts/wpl.sql << EOF
    set serveroutput on size 1000000
    set timing on
    execute wpl_1('0000010676','~')
    execute wpl_2('0000010676','~')
    execute wpl_1('0000010236','FIX')
    execute wpl_2('0000010236','FIX')
    exit
    EOF
    >
    Question: Is it possible to combine the two scripts
    (unix and oracle) together?

  • Running SQLPLUS from UNIX shell script

    I'm not sure if this is the right forum, but...
    How can I execute a sql file from inside the UNIX shell script, logging on to Oracle w/o supplying a UID/pwd? Normally, we log into UNIX using our own logon, then sudo as another user to login to Oracle. Now, I'm trying to create a UNIX shell script, where I'm already sudo'd as the UserID that logs into Oracle. I've tried the following, but can't get it to work. I'm a UNIX scripting noob. Any ideas?
    example:
    #! /usr/bin/ksh
    sqlplus / \@test.sql << EOF
    exit;
    EOF

    I'm a UNIX scripting noob.In which case I feel obligated to point you at William Robertson's excellent article Database Shellscripts Considered Harmful. Save yourself a world of pain.
    Cheers, APC

  • Parameter transfer to tmloadcf from Unix shell script.

    Hi.
    I am using Tuxedo global transaction with database password encryption, so I replaced by ***** the database password in OPENINFO string of the TMS in the UBBCONFIG GROUP section.
    As a result the password should be inserted manually when running tmloadcf.
    Do you know how this password can be inserted from a Unix shell scripts?
    I tried to use << or named pipe (mkfifo) but in both cases the tmloadcf remained stuck.
    Thanks in advance for your help.
    Amnon Katz.

    Amnon,
    The C library function isatty() is used to determine if tmloadcf is
    associated with a terminal. If isatty(0) returns 0, then the tmloadcf code
    to prompt for a password will fail.
    In some places in Tuxedo, there is functionality to allow reading a password
    from an environment variable if the process requiring the password is not
    associated with a terminal. However, this functionality is not available
    for tmloadcf. If you have an active Tuxedo maintenance contract and the
    functionalty of reading a database password from an environment variable
    when tmloadcf is not run from a terminal is important to you, you may want
    to file a support case and request that this functionality be added to
    tmloadcf. Otherwise, you will have to run tmloadcf from a terminal.
    Regards,
    Ed
    <Amnon Katz> wrote in message news:[email protected]..
    Thanks Ed for your reply.
    Do you know how tmloadcf identify that descriptor 0 is associated with a
    terminal?
    Is it possible to write some code that can emulates this situation?
    Regards,
    Amnon

  • How can i call a Stored Procedure procedure from Unix shell script

    Hi All,
    I want to call a Strored PL-SQL Procedure through Unix shell script.
    Can any body help me with this.
    Regards,
    Saurabh

    I prefer a seperate script like the other poster mentioned. However, most shells can use a 'here' document as well ...
    sqlplus uid/pwd <<END
    exec myproc
    exit
    ENDRichard

  • Passing Null Characters from Unix Shell Script to Java Program

    Hi Experts,
    Facing an issue with a shell script....
    The shell script has 10 input parameters....
    1st Parameter is a compiled Java program name(This can keep changing)
    Rest 9 are the parameters of the Java Program...
    The following piece of code is working when Test "a z" "b t" "" "" "" "" "" "" "" "" is hardcoded.
    lv_java_string=`java Test "a z" "b t" "" "" "" "" "" "" "" ""`
    The whole thing being dynamic.....
    But when I dynamically populate the same on to a parameter lv_java_param and then execute the same
    lv_java_string=`java $lv_java_param`
    if i echo $lv_java_param  its giving me Test "a z" "b t" "" "" "" "" "" "" "" ""  correctly
    Im facing some issue...... The issue is " is being treated as a parameter itself and the space between a and z is not taken into consideration and hence z is taken as the 2nd parameter
    Issue seems to be something like the precedence in which the above statement is executed, because of which "s are calculated/manipulated. Is it something like
    a) $lv_java_param is computed  first and then java $lv_java_param
    b) or java $lv_java_param is run on the fly......
    Any help is much appreciated.

    This forum is about Oracle *RDBMS*
    I don't see any question about Oracle RDBMS
    Please find a forum about Java.
    Sybrand Bakker
    Senior Oracle DBA

  • I am unable to set the classpath from unix shell script

    ) I am new to java, provide me the solution to my problem, as it is urgent
    I am unable to execute shell script on unix machine, the code is given below:
    Basically it is not setting the classpath
    dbUpload .java is astand alone java program to retrieve the report instance statistics from crystal server
    Created a jar file from dbUpload.java as
    Jar �cvf dbUpload.jar dbUpload.class
    Here is mycode(script.sh)
    CLASSPATH=/u01/CrystalList/cecore.jar:${CLASSPATH}:
    CLASSPATH=${CLASSPATH}:/u01/CrystalList/cereports.jar:
    CLASSPATH=${CLASSPATH}:/u01/CrystalList/dbUpload.jar:
    Export CLASSPATH
    Echo ${CLASSPATH}
    Java dbUpload

    venkat123,
    if the code you posted is the original code of your script - it has some misspellings. Please try this one - it works for me both on solaris and linux.
    #! /bin/bash
    CLASSPATH=/u01/CrystalList/cecore.jar:$CLASSPATH
    CLASSPATH=$CLASSPATH:/u01/CrystalList/cereports.jar
    CLASSPATH=$CLASSPATH:/u01/CrystalList/dbUpload.jar
    export CLASSPATH
    echo $CLASSPATH
    java dbUpload

  • Calling sqlplus from unix shell script

    Hi All,
    I am executing the following code :-
    sqlplus -s ${DATABASE_USER} |&
    print -p -- 'set feed off pause off pages 0 head off veri off line 500'
    print -p -- 'set term off time off serveroutput on size 1000000'
    print -p -- "set sqlprompt ''"
    print -p -- "SELECT run_command from tmp_run_batch where upper(batch_name) = upper('${PAR_PROGRAM_NAME}');"
    read -p RUN_COMMAND
    eval print -p -- \""execute dbms_output.put_line(${RUN_COMMAND});"\"
    read -p RET_VAL
    print -p -- "exit;"
    The select stmt given above gives sample output as :-
    pack_claims_clas_utils.func_main('$PAR_RUN_DATE','$PAR_RUN_LEVEL','$PAR_EXCLUSIVE_RUN_YN')
    And then this package is executed.
    The problem that I am facing is how to handle the no_data_found case of the select stmt. . When this case arises then the stmt. "read -p RUN_COMMAND" hangs.
    Could you please provide any solution ?
    Thanks
    Suds

    Hi,
    Have you tried this:
    # if [ -n means String has non-zero length
    if [ -n $RUN_COMMAND ]
    read -p RUN_COMMAND
    fi
    Hi All,
    I am executing the following code :-
    sqlplus -s ${DATABASE_USER} |&
    print -p -- 'set feed off pause off pages 0 head off veri off line 500'
    print -p -- 'set term off time off serveroutput on size 1000000'
    print -p -- "set sqlprompt ''"
    print -p -- "SELECT run_command from tmp_run_batch where upper(batch_name) = upper('${PAR_PROGRAM_NAME}');"
    read -p RUN_COMMAND
    eval print -p -- \""execute dbms_output.put_line(${RUN_COMMAND});"\"
    read -p RET_VAL
    print -p -- "exit;"
    The select stmt given above gives sample output as :-
    pack_claims_clas_utils.func_main('$PAR_RUN_DATE','$PAR_RUN_LEVEL','$PAR_EXCLUSIVE_RUN_YN')
    And then this package is executed.
    The problem that I am facing is how to handle the no_data_found case of the select stmt. . When this case arises then the stmt. "read -p RUN_COMMAND" hangs.
    Could you please provide any solution ?
    Thanks
    Suds

  • RFC_REMOTE_PIPE is Returning 1 alwasys and not able to execute Unix shell script

    Hello All,
    I am trying to execute a simple unix shell script from ABAP.
    What I did so far..
    1. created a test.sh file  with single command echo "Hello".
    2.  placed this file on application server /Usr/sap/test.sh
    3. executing ABAP program which as FM RFC_REMOTE_PIPE
    CODE:
    CALL FUNCTION 'RFC_REMOTE_PIPE'
       DESTINATION 'SERVER_EXEC'
    EXPORTING
       command  = lv_command
       read          = 'X'
    TABLES
       pipedate    =  lt_stdout
    EXCEPTIONS
    system_failure  = 1
    communication_failure = 2.
    if i populate lv_command  = echo "hello" it works fine
    if i give .sh file path in lv_command it is not working. it returns 1.
    Please help...
    I was searching SDN i found that rfcexec service should be enabled... how do i check that..
    i checked t code  \SMGW , i don't see any output...
    i checked FM GWY_READ_CONNECTED_SYSTEMS, i don't hsee anyting related to unix...
    Please suggest.

    I resolved the issue.
    It was issue with permission.
    Script file should have full permission ( Mode 777)..
    Thanks everyone.

  • Error while trying to execute a unix shell script from java program

    Hi
    I have written a program to execute a unix shell script in a remote machine. I am using J2ssh libraries to estabilish the session connection with the remote box.The program is successfully able to connect and authenticate with the box.
    The runtime .exec() is been implemented to execute the shell script.I have given below the code snippet.
    try {
         File file_location = new File("/usr/bin/");
         String file_location1 = "/opt/app/Hyperion/scripts/daily";
         String a_mib_name = "test.sh";
         String cmd[] = new String[] {"/usr/bin/bash", file_location1, a_mib_name};
         Runtime rtime = Runtime.getRuntime();
         Process p = rtime.exec(cmd, null, file_location);
    System.out.println( "Connected to the server1" );
    BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
    String line = br.readLine();
    while(line !=null)
    System.out.println(line);
    line = br.readLine();
    br.close();
    p.getErrorStream ().close ();
    p.getOutputStream().close();
    int retVal = p.waitFor();
    System.out.println("wait " + retVal);
    //session.executeCommand("ls");
    catch (IOException ex) {
    I get an error message
    Connected to the server
    java.io.IOException: Cannot run program "/usr/bin/bash" (in directory "\usr\bin"
    ): CreateProcess error=3, The system cannot find the path specified
    at java.lang.ProcessBuilder.start(Unknown Source)
    at java.lang.Runtime.exec(Unknown Source)
    at SftpConnect.main(SftpConnect.java:143)
    Caused by: java.io.IOException: CreateProcess error=3, The system cannot find th
    e path specified
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(Unknown Source)
    at java.lang.ProcessImpl.start(Unknown Source)
    I am sure of the file path where the bash.sh and test.sh are located.
    Am i missing something? Any help would be greatly appreciated.
    Thanks
    Senthil

    Hi, I am using a simple program to connect to a RMI server and execute shell script. I use the Runtime.exec aommand to do the same.
    The script is sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul
    The script when run from the server, gives no errors. But when ran using rthe above method in java, gives errors as follows,
    Mycode:
    String command = "/bin/sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul";
    Runtime rt = Runtime.getRuntime();
    Process proc = rt.exec(command);
    int exitVal = proc.exitValue();
    System.out.println("Process exitValue: " + exitVal);
    java.io.IOException: CreateProcess: /bin/sh /tmp/pub/alka/test.sh /tmp/pub/alka/abc/xyz/ul ul error=3
         at java.lang.ProcessImpl.create(Native Method)
         at java.lang.ProcessImpl.<init>(Unknown Source)
         at java.lang.ProcessImpl.start(Unknown Source)
         at java.lang.ProcessBuilder.start(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at DecryptTest.main(DecryptTest.java:18)
    Can anyone please help

  • Error while executing unix shell script from java program

    Hi All,
    I am trying to execute unix shell script from a java program using Runtime.execute() method by passing script name and additional arguments.
    Code snippet :
    Java Class :
    try{
         String fileName ="test.ksh";
         String argValue ="satish"; // value passed to the script
         String exeParam = "/usr/bin/ksh "+fileName+" "+argValue;
         Process proc = Runtime.getRuntime().exec(exeParam);
         int exitValue = proc.waitFor();
         sop("Exit Value  is : "+exitValue);
    catch(Exception e)
    e.printStackTrace();
    }Test.ksh
      export -- application realated paths..
      nohup  abc.exe 1> test.log 2>&1;
      $1
      exit.By running the above java class , i am getting exit Value: 139 and log file test.log of 0 bytes.
    when i am running the same command (/usr/bin/ksh test.ksh satish) manually, it's calling abc.exe file successfully
    and able generate the logs properly.
    Pls let us know where exactly i am stuck..
    Thanks in advance,
    Regards,
    Satish

    Hi Sabre,
    As per the guidelines provided by the article, i had done below changes..
    InputStream is = null;
    InputStreamReader iStreamReader = null;
    BufferedReader bReader = null;
    String line = null;
    try{
    String fileName ="test.ksh";
    String argValue ="satish"; // value passed to the script
    String exeParam = "/usr/bin/ksh "+fileName+" "+argValue;
    Process proc = Runtime.getRuntime().exec(exeParam);
    is = proc.getErrorStream();
    iStreamReader = new InputStreamReader(is);
    bReader = new BufferedReader(iStreamReader);
    System.out.println("<ERROR>");
    while((line = bReader.readLine()) != null)
    System.out.println("Error is : "+line);
    System.out.println("</ERROR>");
    int exitValue = proc.waitFor();
    sop("Exit Value is : "+exitValue);
    catch(Exception e)
    e.printStackTrace();
    Now , it's showing something like..
    <ERROR>
    </ERROR>

  • How to execute unix shell script from Java ...

    Hi,
    Anyone know how to execute unix shell script from Java?
    Suppose I have several shell scripts written in perl or tcl or bash.
    I just want to catch the output of that script.
    Is there any ready to use module/object for this?
    Please let me know, this is quite urgent for my study assigment.
    Thanks in advance,
    Regards,
    me

    Look up Runtime.exec()

Maybe you are looking for

  • "copy and paste text within symbol" bug

    I am sure this has been discussed, but have not found it using search. Follow these steps to demonstrate a "Symbol Text" bug (CS5 through CC 2014): Create Symbol containing editable text. Edit symbol by selecting and copying a portion of text at "Cha

  • Resizing tabs in forms 5

    i have set the window size to be w=590 h=333 the size of tab canvas is w=580 h=328 the problem is that when i run forms, the database objects that reside after 350( x axis) gives an error that objects falls out of canvas. how can i resolve this probl

  • How to set my MacPro to not go to sleep

    I am running Euphonix MC control. They recommend: It is recommended that you do not set your EuCon workstation(s) to Sleep. We recommend setting your Mac to not go to sleep and never put hard drives to sleep.

  • How to compare two tables in SSIS?

    I am creating an SSIS package that will compare two tables and then insert data in another table. Which tool shall I use for that? I tried to use "Conditional Split" but it looks like it only takes one table as input and not two. These are my tables:

  • HT4865 does every iphone user in my house have to have their own itunes account?

    Up untill now my wife and I have shared one itunes account, namely mine. Now my 14 year old daughter has earned her own Iphone and her two brothers are sure to follow. My question is... How should we manage all our information now. Should each user h