Java program in UNIX environment

Hi All,
Could you please help me with how to configure a java program in UNIX environment..
that is to schedule it to run every day from cron..
I need to know what are the basic things we require to achieve the above..
I guess it is:
A script
A config file containing db login details
oher than this I don?t know what is required plz help

You can execute any jar or class file with cron. If you are using a jar you might use something like java -jar /usr/bin/myapp.jar .
I use Linux, this is my area of expertise.
Here is an online guide "for complete newbies" on how to set up cron.
http://www.unixgeeks.org/security/newbie/unix/cron-1.html
Hope it helps.

Similar Messages

  • Execute java program on UNIX

    I have no experience on Unix and I now need to try to execute my java program on UNIX server to which I connect using telnet. I have copy my source file to the server and I could run the javac command to compile my source code.
    In the current directory, I just execute "javac mySource.java"
    And I got my .class file on the same directory. But when I tried to execute "java mySource", I got NoClassDefFoundError. I think it has something to do with classpath. But I just don't know how to do it in UNIX. Please someone assist me. Thanks.

    Or setenv CLASSPATH $CLASSPATH:/your/classpath/here if you are running csh.

  • I want to run java program on windows environment as background process

    Hi all
    I want to run java program on windows environment as background processSo command prompt return after executing java command and program on background In Linux we can do this easily �but I do not how to do this in windows
    for example look this programe
    import java.io.*;
    import java.util.*;
    public class TestClass {
         class ravi extends Thread{
              public void run(){
                   try {    
                        String target_file = "ravind.txt";
                        File targetfile = new File(target_file);
                        PrintWriter writer = new PrintWriter(new FileWriter(targetfile)) ;
                   for (int i =0 ; i < 100 ;i++ ){
                        Thread.sleep(10000);
                        writer.println(" ravindra shukla ");
              } catch (Exception e) {               
                             e.printStackTrace();
         public static void main(String[] args) {
              TestClass test1 = new TestClass();
              TestClass.ravi r1 = test1.new ravi();
              r1.start();          
    System.out.println(" return from main ");
    first i compile this
    javac TestClass.java
    then i run this by using this command
    java TestClass
    but becouse i put sleep on threads run function so it takes to much time to get return on command promt .... i want to run this programe as background process so command promt return as soon as i execute java command

    Thanks dude
    This solution �start java TestClass� works fine �. But it does not solve my problem
    It opens another black window and that black window persist till the life time of my program
    Is it possible application run on complete background without opening another black window �as in Linux

  • Can I run my java program in windows environment?

    How can i make my compiled java program run into windows environment?
    What program will i use to be able to do that?

    1. Install the JRE.
    2. Go to the command line.
    3. Type something like java myClass or java -jar myJar.jar.
    You could also use one of the many java2exe (java to executable) programs floating out there.

  • Launching a Java Program from UNIX ( C/C++ )

    How do I launch my Java program from c/c++? Do I need to wrap my java command line ( ie. java -classpath .... ) in a C shell ? Is there another way?

    How do I launch my Java program from c/c++? Do I need
    to wrap my java command line ( ie. java -classpath
    .... ) in a C shell ? Is there another way?You can do it directly using Java Native Interface (JNI). Using this approach the Java program runs in the current process.
    Sylvia.

  • Running Pro*C program in Unix environment.

    I have a program developed in Pro*C running on AIX version 5.3 and at the moment compiled in a 10g release 2 environment.
    This program find some job to start via a system() call. On previous release of Oracle software I have the possibility to get error detected in these job, but now every job return error code 0!
    I have found out that it easily can be seen, if you start a sqlplus on the unix commandline and start a host command (!) inside this sqlplus, then all command called from this new unix prompt will return error code 0, and no error can be detected! Try run the command diff x y where file x and y does not exist, and see the error code (type echo $?).
    My question is have anyone seen this problem, and have somebody found a solution? My guess is that it is a problem in the AIX port, but I have not the possibility to try on other hardware running Unix.

    unix> uname -a
    AIX david 3 5 00C5E53B4C00
    unix> echo My C-program
    My C-program
    unix> diff x y
    diff: x: A file or directory in the path name does not exist.
    diff: y: A file or directory in the path name does not exist.
    unix> echo $?
    2
    unix> ./bostst1 ksh
    tor 12 okt 09:09:20 2006
    unix> diff x y
    diff: x: A file or directory in the path name does not exist.
    diff: y: A file or directory in the path name does not exist.
    unix> echo $?
    2
    unix>
    unix> echo My Pro*C program:
    My Pro*C program:
    unix> diff x y
    diff: x: A file or directory in the path name does not exist.
    diff: y: A file or directory in the path name does not exist.
    unix> echo $?
    2
    unix> ./bostst ksh
    Dato: 2006.10.12 09:13:15
    unix> diff x y
    diff: x: A file or directory in the path name does not exist.
    diff: y: A file or directory in the path name does not exist.
    unix> echo $?
    0
    unix> sqlplus scott/tiger
    SQL*Plus: Release 10.2.0.1.0 - Production on To Okt 12 09:13:55 2006
    Copyright (c) 1982, 2005, Oracle. All rights reserved.
    Forbindelse er oprettet til :
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL> !diff x y ; echo $?
    diff: x: A file or directory in the path name does not exist.
    diff: y: A file or directory in the path name does not exist.
    0
    SQL>
    I hope this show the problem !!!
    On what platform are you (Kamal Kishore) running?

  • Running a .jar with a java program on unix

    I am trying to run a jar file with this java code but when i run it, it comes up with built successfully but the file doesn't run.
    ps- I use a unix os
    public class Main {
    public static void main(String args[]) throws IOException, InterruptedException {
    // first method i tried:
    Runtime.getRuntime().exec( new String[] {"/bin/sh", "-c",
    "/Users/cb/NetBeansProjects/MultiCalc/dist/MultiCalc.jar output.out ascii workload2.trace 0"});
    //second method i tried:
    ProcessBuilder pb = new ProcessBuilder( new String[] {"/bin/sh", "-c",
    "/Users/cb/NetBeansProjects/MultiCalc/dist/MultiCalc.jar"});
    pb.redirectErrorStream( true );
    pb.start();
    thanks a lot in advance!

    javalavaguava-- wrote:
    I am trying to run a jar file with this java code but when i run it, it comes up with built successfully but the file doesn't run.
    ps- I use a unix os
    public class Main {
    public static void main(String args[]) throws IOException, InterruptedException {
    // first method i tried:
    Runtime.getRuntime().exec( new String[] {"/bin/sh", "-c",
    "/Users/cb/NetBeansProjects/MultiCalc/dist/MultiCalc.jar output.out ascii workload2.trace 0"});
    //second method i tried:
    ProcessBuilder pb = new ProcessBuilder( new String[] {"/bin/sh", "-c",
    "/Users/cb/NetBeansProjects/MultiCalc/dist/MultiCalc.jar"});
    pb.redirectErrorStream( true );
    pb.start();
    thanks a lot in advance!I don't see any mention of 'java' when trying to execute the jar file. You have to specify which application should process a jar file - it doesn't magically know to use java.
    P.S. You should read the 4 sections of [http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html|http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html] and implement ALL the recommendations.

  • How to run a spool program in unix environment within a shell script

    Hi
    I have written a spool program , which i run from SQL * PLUS
    using
    @'path of the spool file having extension .sql'
    Now i want to include this spool program within the shell script , please help me , how to do it.
    Thanks in advance ..

    user8703472 wrote:
    Thank You Sir for the reply .
    #!/bin/ksh
    ORACLE_SID=<SID>; export ORACLE_SID
    ORACLE_HOME=<ORACLE_HOME>; export ORACLE_HOME
    $sqlplus / as sysdba <<-EOFSQL1 >> output.log 2>&1
    spool /tmp/a.log
    select * from v\$instance
    spool off;
    EOFSQL1
    Please explain me this statement $sqlplus / as sysdba
    and also what a.log contains .
    i have the user id and password for the DB.
    should i write something like this
    $sqlplus -Uusername -Ppassword -Sservername
    i know how to run a procedure from isql(sybase DB)
    Ahh.... but oracle is not just sybase under a different name.
    It would be a good investment in your career to go to tahiti.oracle.com. Drill down to your product and version. There you will find the complete doc library.
    You should spend a few minutes just getting familiar with what kind of documentation is available there by simply browsing the titles under the "Books" tab.
    Open the Reference Manual and spend a few minutes looking through the table of contents to get familiar with what kind of information is available there. Learning where to look things up in the documentation is time well spent on your career.
    For your immediate task, spend a few minutes looking through the SQLPlus User Guide and Reference.
    Then set yourself a plan to dig deeper.
    - Read a chapter a day from the Concepts Manual.
    - Look in your alert log and find all the non-default initialization parms listed at instance startup. Then read up on each one of them in the Reference Manual. Take a look at your listener.ora, tnsnames.ora, and sqlnet.ora files, then bounce what you see there in the network administrators manual.
    Give a man a fish and he eats for a day. Teach a man to fish and he eats for a lifetime.
    But this project , i need to run the spool program from with in a shell script .We see what you mean, but the term "spool program" has no meaning in Oracle and only serves to cloud the issue. I know you are used to using this term with other products, but "When in Rome ...."
    >
    Thank You in advance ..

  • Pro*Cobol in VMS to Unix environment

    Please let me know if I can use my current Pro*Cobol programs in
    Unix environment. We are planning to convert our platform to
    Unix. Presently I am using DCL on VMS. Thanks in advance for all
    your answers
    null

    HI
    It will still support Cobol in order to cater to the clients who are still in mainframe systems and those clients who have their legacy systems in Cobol.
    Regards,
    Bibs

  • Running Java app on UNIX

    Hi all, Any kind of help is much appreciated.
    I am trying to run a Java program on Unix which also imports packages of a 3rd party vendor.
    I run it from the directory where i have my MyProgram.java file stored and also provide the classpath for the .jar/.zip files of the 3rd party vendor (using -classpath option with javac)
    Compiling is clean with no errors.
    But, on running the java command: java MyProgram
    It gives me java.lang.NoClassDefErrorFound for a class which came with the 3rd party vendor.
    The class is present in the .jar file, which I provided in the -classpath option with javac. There are many other classes present in the same .jar file which are being used in the program but it just gives the error for this particular class.
    -I also tried by saving that class in my current directory and compiled it with
    javac <-classpath> MyProgram.java 3rdVendor.java
    command and created its .class file in the current directory but then again using java command from the same directory gives the same error: java.lang.NoClassDefFoundError
    Plzz....help
    Thanx Shaan

    here is the command i used
    javac -classpath .:/home/top/MyName/dir1/jcommom-0.9.7/jcommon-0.9.7.jar:/home/top/MyName/dir1/jfreechart-0.9.21/jfreechart-0.9.21.jar DyanmicChart.java
    COMPILATION IS WITH NO ERRORS
    and then I run java from the same directory where i have DynamicChart.class built
    java DynamicChart
    error in class Main : java.lang.NoClassDefFoundError for org/jfree/data/time/RegularTimePeriod
    RegularTimePeriod is present in jfreechart-0.9.21.jar and its .java file is located in the folder jfreechart-0.9.21/source/org/jfree/data/time/RegularTimePeriod.java
    There are lot of other classes that I use from .jar files mentioned in the classpath but its just this one class. I also saved the RegularTimePeriod.java file in the pwd to built its .class in the current directory and compiled it using the above (javac) command with DynamicChart.java. AGAIN NO COMPILATION ERRORS...but the same error when i run: java DynamicChart
    Shaan

  • Using a UNIX shell script to run a Java program (packaged in a JAR)

    Hi,
    I have an application (very small) that connects to our database. It needs to run in our UNIX environment so I've been working on a shell script to set the class path and call the JAR file. I'm not making a lot of progress on my own. I've attached the KSH (korn shell script) file code.
    Thanks in advance to anyone who knows how to set the class path and / or call the JAR file.
    loggedinuser="$(whoami)"
    CFG_DIR="`dirname $0`"
    EXIT_STATUS=${SUCCESS}
    export PATH=/opt/java1.3/bin:$PATH
    OLDDIR="`pwd`"
    cd $PLCS_ROOT_DIR
    java -classpath $
    EXIT_STATUS=$?
    cd $OLDDIR
    echo $EXIT_STATUS
    exit $EXIT_STATUS

    Hi,
    I have an application (very small) that connects to
    our database. It needs to run in our UNIX environment
    so I've been working on a shell script to set the
    class path and call the JAR file.
    #!/bin/sh
    exec /your/path/to/java -cp your:class:paths:here -MoreJvmOptionsHere your.package.and.YourClass "$@"Store this is a file of any name, e.g. yuckiduck, and then change the persmissions to executechmod a+x yuckiduckThe exec makes sure the shell used to run the script does not hang around until that java program finishes. While this is only a minor thing, it is nevertheless infinite waste, because it does use some resources but the return on that investment is 0.
    CFG_DIR="`dirname $0`"You would like to fetch the directory of the installation out of $0. This breaks as soon as someone makes a (soft) link in some other directory to this script and calls it by its soft linked name. Your best bet if you don't know a lot of script programming is to hardcode CFG_DIR.
    OLDDIR="`pwd`"
    cd $PLCS_ROOT_DIRVery bad technique in UNIX. UNIX supports the notion of a "current directory". If your user calls this program in a certain directory, you should assume that (s)he does this on purpose. Making your application dependent on a start in a certain directory ignores the very helpful concept of 'current directory' and is therefore a bug.
    cd $OLDDIRThis has no effect at all because it only affects the next two lines of code and nothing else. These two lines, however, don't depend on the current directory. In particular this (as the cd above) does not change the current directory for the interactive shell your user is working in.
    echo $EXIT_STATUS
    exit $EXIT_STATUSEchoing the exit status is an interesting idea, but if you don't do this for a very specific purpose, I recommend not to do this for the simple reason that no other UNIX program does it.
    Harald.

  • Running java program with arguments in Unix

    Hi
    I am a new newbie to java so pardon if this is too simple for you .
    This is my scenario. I have a java program which parses an xml and writes a .dat file. I execute this testparser.java in unix environment like this
    java testparser xml1.xml
    and it retuns me a .dat file
    But my issue is I have to run my parser program for 40 xml files. The requirement is I have to create a script file and possibly with a for loop which will loop through 1-40 xml files and return me the .dat file.
    I am really at a loss here. I am new both to Java and Unix
    So pls help me out
    Thanks in Advance
    G

    You could just do this in Java. Make it take all 40 xml files on the command line, and convert them all with one program invocation.
    If you want to do it in shell script, you can do something like
    for tmp in `ls -1 *.xml`; do
      java testparser $tmp
    donedepending on your shell, etc.

  • Talking to Unix from Win32 Java program

    Hi,
    Im writing a program that is run in windows, but it needs to interface with a unix system. Is there any api's in java that will allow me to communicate with unix from a windows environment? I need to be able to send basic commands to the unix system from my program such as "cd dir" and "ls" and feed the output back to my program. I've had a look at the standard java.io package but this only lets me communicate with unix when the program itself is run from a unix environment. I would be grateful for any ideas.
    Thanks

    well you can use "Socket/ServerSocket" class, if you want to send/recieve data it will work.....
    I created a chat using that, one runs on Win32 and the other is on Unix.....

  • 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>

  • Machine environment for running a java program

    Hi,
    I am thinking about writing a client-server application. The communication between the server and the client and vice versa will be in RMI. My question is regarding the client machine environment - do I need to install JDK on the client machine in order to run the client? Can the client run on any environment?
    Thanks

    Hi,
    I am thinking about writing a client-server
    application. The communication between the server and
    the client and vice versa will be in RMI. My question
    is regarding the client machine environment - do I
    need to install JDK on the client machine in order to
    run the client? Can the client run on any environment?
    ThanksHow do java programs run?
    Compiled Java programs are stored in files as bytecode. As a Java program is running, the Java Virtual Machine (JVM), which is a piece of software, converts the bytecode into machine executable code for the particular platform on which the program is running. This code is what is executed by the processor. Bytecode is not specific to a particular platform, but the machine code generated by the JVM is.
    [url http://www.webopedia.com/TERM/J/JVM.html] definition of JVM as per webopedia[ [/url]
    Hopefully now you have an answer to your question.

Maybe you are looking for

  • My ipod will no longer sync music, any suggestions?

    lMy ipod will no longer sync music. I have windows 8 and a windows XP, and it won't sync in either program. Suggestions?

  • How to set a blog as start page

    Hi There, Liek to set my blog as a startpage but the link, in the dropdown menu, under blog "set as starpage" is not working. Is ther soemeone who knows a solution? Thanks Rolf

  • Gaming properly: using a ps3 pavigator

    I have a PS3, I have a Wii, I love motion controllers for gaming. -I've tride a few different how-tos for conecting the dualstick controller to the PS3, and they don't work, I suspect the culprit has to do with getting it to pair properly. Ultimatly

  • POWL UI Element in ESS- My Trips and Expenses Application

    Hi Experts, There is an application My Trips and Expenses in ESS. The WD ABAP component for which is FITV_POWL_TRIPS. In the application we can see a TabStrip UI element on which there is an ALV on "All My Expense Reports" Tab. I want to hide the "At

  • How do I make my Flash player default?

    Since Yosemite was installed on my macbook pro my video player which worked perfectly has changed over to AirPlay without my knowledge. It will not play anything, no matter how many times I click the box. I have tried to reset my Flash Player to defa