Results 1 to 4 of 4

Thread: How to run java on UNIX

  1. #1
    Join Date
    Oct 2010
    Posts
    96

    How to run java on UNIX

    I want to know that can i run java language in UNIX system, if yes then how, I had not used UNIX till yet, but if i install UNIX in my system then, can i run java on it. I have used operating system like windows xp, vista,windows 7, but never used UNIX or LINUX. please tell me the procedure of installing java on UNIX and how to run java on it.

  2. #2
    Join Date
    May 2008
    Posts
    913

    Re: How to run java on UNIX

    Yes you can run a JAVA language in UNIX system because java is platform independent language.To run a java program you have to first install a jdk software of java in your system. There are different versions in jdk like jdk1.0,jdk2.0,jdk3.0.....jdk5.0. Any version will get compatible with your system. After installing you have to run java program from unix shell script.You must have jar files and classpath execution stuff.Below script will help you to run java program in any location.


    #!/bin/sh
    #- Main Base directories
    chmod 777 thisshellscriptname.sh
    echo "******* Enter your tool or project title *********"
    # If you want some input from user
    echo 'Enter Java Location************'
    # or
    # if you want java location
    read varname
    # Base dir path here (where your related jar files are located)

    BASE_DIR="type path here"

    #- Main .jar files
    YOUR_JAR={BASE_DIR}/lib/YOUR_JARFILE.jar"
    #- java
    JAVA_EXECUTABLE="/usr/java/bin/java"
    JAVA_HOME=`dirname /usr/java/bin/java`"/.."
    #- main classpath

    YOURCLASSPATH=.:${YOUR_JAR}

    #- launching command
    echo '**************YOUR TOOL NAME *************'
    /usr/jdk1.5.0/bin/java -cp $YOURCLASSPATH MainClassFileName
    # or

    $varnamejava -cp $YOURCLASSPATH MainClassFileName
    echo 'Successfully *****'
    exit 0
    Now you can run java program on your UNIX system.

  3. #3
    Join Date
    Nov 2008
    Posts
    1,054

    Re: How to run java on UNIX

    To run java program you must compile a java program in UNIX environment for that you must trigger jdk setup file. Follow the steps to do it :
    1).Open your .login file for editing e.g., by typing > pico .login
    if you are using a pico editor.

    2). Go to the end of the .login file and add the following code in there (Make sure you do not make any other changes)

    ###########################################################################
    #
    # Source the jdk files
    #
    if (-r /usr/usc/jdk/1.4.2/setup.csh) then
    source /usr/usc/jdk/1.4.2/setup.csh
    endif
    ###########################################################################

    3).Save the modified .login file.
    4).Now you need to source the modified .login file by typing
    > source .login
    now you can start compiling your java program.

  4. #4
    Join Date
    May 2008
    Posts
    979

    Re: How to run java on UNIX

    You can execute your java program on UNIX. You must installed jdk first and should compile the code. after compiling you need to execute your code.To execute already compiled code prog_Name.java, you have to type
    > java prog_Name at the UNIX prompt. Again, you must be in the directory where your program was compiled.

Similar Threads

  1. how to connect vb with unix
    By Mewad in forum Operating Systems
    Replies: 5
    Last Post: 03-01-2011, 07:13 PM
  2. Unix Toolbox
    By visioneye in forum Windows Software
    Replies: 6
    Last Post: 13-05-2010, 10:45 PM
  3. Where can i get OpenBSD Unix
    By Steyn in forum Operating Systems
    Replies: 3
    Last Post: 20-08-2009, 04:44 PM
  4. To run Linux AIM in Unix ?
    By Ebenezer in forum Operating Systems
    Replies: 3
    Last Post: 19-03-2009, 02:55 PM
  5. Learn UNIX!
    By rupak in forum Ebooks
    Replies: 4
    Last Post: 14-08-2008, 02:08 PM

Posting Permissions

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