Results 1 to 5 of 5
  1. #1
    bad biddy is offline Member
    Join Date
    Mar 2012
    Posts
    51
    Rep Power
    0

    Default Automating 3 java programs with a script

    I'm trying to finish this lab for homework. It consists of 3 related java programs and at least one of them uses an operating system call.

    Here is the 3 java programs

    This one is to determine OS


    [root@engagelinux ~]# cat DetermineOs.java
    public class DetermineOs{

    public static void main(String[]args){


    //get os.name system property using public static String getProp erty(String name) method of system class

    String strOSName = System.getProperty("os.name");

    System.out.print("Get OS name example..OS is ");

    if(strOSName !=null)
    {

    if(strOSName.toLowerCase().indexOf("windows") !=-1)

    System.out.println("Windows");
    else
    System.out.print("not windows, but ");
    System.out.print(strOSName);
    System.out.println(" ");

    }
    }
    }


    This one gets the system time.

    [root@engagelinux ~]# cat GetSystemTime.java
    public class GetSystemTime {

    public static void main(String[]args){

    long lnSystemTime = System.currentTimeMillis();

    System.out.println("Milliseconds since midnight, January 1, 1970 UTC: "
    + lnSystemTime);
    }
    }


    This one prints the class path

    [root@engagelinux ~]# cat PrintClassPath.java
    public class PrintClassPath{

    public static void main(String[]args){

    String strClassPath = System.getProperty("java.class.path");
    System.out.println("ClassPAth is " + strClassPath);

    }
    }



    Now this is the script to run all three

    [root@engagelinux ~]# cat java3con.sp
    echo run 3 java classes concurrently
    java DeterminOs
    java PrintClassPath
    java GetSystemTime
    echo end of script


    Here is the error i get when running the script:

    [root@engagelinux ~]# ./java3con.sp
    run 3 java classes concurrently
    ./java3con.sp: line 2: java: command not found
    ./java3con.sp: line 3: java: command not found
    ./java3con.sp: line 4: java: command not found
    end of script


    How can i change it to get it to run?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,037
    Rep Power
    10

    Default Re: Automating 3 java programs with a script

    Can you use java without a script? Can you compile and run things from the command line?

    Recommended reading: Lesson: Common Problems (and Their Solutions) (The Java™ Tutorials > Getting Started)
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    bad biddy is offline Member
    Join Date
    Mar 2012
    Posts
    51
    Rep Power
    0

    Default Re: Automating 3 java programs with a script

    I had a grammar error within the script. Fixed it but for some reason the class path part is not displaying what i want.

    I want it to display the class path of mysql-connector-java-5.1.18.bin.jar that i have downloaded into my root folder system


    [bdewall@hermes ~]$ ./java3con.sp
    run 3 java classes concurrently
    Get OS name example..OS is not windows, but Linux
    ClassPath is .
    Milliseconds since midnight, January 1, 1970 UTC: 1333047581364
    end of script

  4. #4
    bad biddy is offline Member
    Join Date
    Mar 2012
    Posts
    51
    Rep Power
    0

    Default Re: Automating 3 java programs with a script

    I think I'll be able to figure it out. I'll be testing it out in a hour

  5. #5
    bad biddy is offline Member
    Join Date
    Mar 2012
    Posts
    51
    Rep Power
    0

    Default Re: Automating 3 java programs with a script

    Got it all figured out. Mods can lock this thread.

Similar Threads

  1. Java Network Programs
    By sixxvirus in forum New To Java
    Replies: 5
    Last Post: 03-04-2012, 09:00 AM
  2. How to make 11 java programs into one.
    By decgaid06 in forum New To Java
    Replies: 6
    Last Post: 03-29-2011, 07:23 PM
  3. Automating task using recursive threads
    By jitheshmenon in forum Threads and Synchronization
    Replies: 1
    Last Post: 08-10-2010, 05:41 PM
  4. Automating Web application using Java API
    By BikuDAA in forum AWT / Swing
    Replies: 0
    Last Post: 04-27-2010, 09:27 PM
  5. Putting Java Programs on a DVD
    By matt.monkeyboy in forum Advanced Java
    Replies: 4
    Last Post: 04-05-2010, 04:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •