Results 1 to 10 of 10
  1. #1
    bhupal4all's Avatar
    bhupal4all is offline Member
    Join Date
    Sep 2008
    Posts
    13
    Rep Power
    0

    Post [SOLVED] Necessary Variables to run

    Hi,

    Could you tell me what are the necessary variables to run a simple java application and why?

    Thanks in advance.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    To run a simple Java application you only need a main method, that's it. Better to more descriptive in your question.

  3. #3
    bhupal4all's Avatar
    bhupal4all is offline Member
    Join Date
    Sep 2008
    Posts
    13
    Rep Power
    0

    Default

    Sorry, I mean what I need to set in environment (variables).

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Ah, I got the point. You want to set the class path.

    Actually you can do it in two ways.

    1) If you are working on command prompt, you can set the class path at the time of working on with Java applications. But this is not a good choice actually, reason is that each time you start work need to set the class path.

    Say you install Java in following path,

    C:\Java
    What you have to do is, change your directory to the working folder and then type

    path=C:\Java\jdk1.5\bin
    Actually path to the bin folder, it can be differ depends on your JDK version and installation path. To check class path setting is fine, type javac and see what the result is.

    2) On Environment Variables, on Path variable of User Variables at the class path to the end of it.

  5. #5
    sagarbirari is offline Member
    Join Date
    Sep 2008
    Posts
    17
    Rep Power
    0

    Default

    2 variable needed PATH and CLASSPATH

    In PATH add path of bin directory of java
    path=C:\Program Files\Java\jdk1.5.0_06\bin;

    IN CLASSPATH add psth of lib directory of java
    classpath=C:\Program Files\Java\jdk1.5.0_06\lib;

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  7. #7
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,565
    Rep Power
    25

    Default

    You don't NEED to set any environment variables to run a java program. You can always specify full paths to the command and the full classpath on the commandline.
    Setting the environment variables shortens what you have to type in, prevents typos on long paths and can make it easier. However, forgotten settings for the classpath can come back to bite you.

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Yes, that's my first option. ;) But the worst thing there is each time you have to set the path. You can do it in many ways. Simple way I use is,

    working_folder>path=C:\Java\jdk1.5\bin\
    according to my installation.

    And also if you want you can edit the autoexec.bat file. So need to worry about the class path when you running application again.

  9. #9
    bhupal4all's Avatar
    bhupal4all is offline Member
    Join Date
    Sep 2008
    Posts
    13
    Rep Power
    0

    Default

    Thanks to All for giving information :)

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Help with muliplying two variables
    By michael.dunkling in forum New To Java
    Replies: 12
    Last Post: 07-18-2008, 09:22 PM
  2. Collecton of Variables
    By c26354 in forum New To Java
    Replies: 12
    Last Post: 06-30-2008, 03:09 PM
  3. Variables
    By mew in forum New To Java
    Replies: 3
    Last Post: 12-11-2007, 12:44 PM
  4. variables-methods
    By Warren in forum New To Java
    Replies: 1
    Last Post: 11-28-2007, 04:14 PM
  5. Saving Variables
    By Fish in forum New To Java
    Replies: 6
    Last Post: 06-25-2007, 08:20 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
  •