Results 1 to 3 of 3
  1. #1
    pharaon is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Default cmd "java hello" run from different directory

    Hello!
    I'm starting to learn programming. I have a simple java program, which i want to run from command line.
    I go to folder which holds the .class file and run "java hello". This works fine.
    But i want to execute this command from other directories (ex: C:\) and not from C:\workspace\test\bin.
    How do i write this command?

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,750
    Rep Power
    19

    Default Re: cmd "java hello" run from different directory

    java -cp "<path to the root directory holding your class files/packages>" hello
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    pharaon is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Default Re: cmd "java hello" run from different directory

    Just what i needed, thanks Tolls!

Similar Threads

  1. Replies: 1
    Last Post: 02-01-2012, 08:37 PM
  2. Replies: 5
    Last Post: 12-21-2011, 06:44 PM
  3. setting the "Java classes" directory in Linux
    By mr_anderson in forum Advanced Java
    Replies: 1
    Last Post: 08-02-2010, 07:18 AM
  4. Java, Military Format using "/" and "%" Operator!!
    By sk8rsam77 in forum New To Java
    Replies: 11
    Last Post: 02-26-2010, 03:03 AM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 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
  •