Results 1 to 7 of 7

Thread: problem running java program

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,168

    problem running java program

    i can run my java program if the .class(which is the main) is in the bin directory of java. I just type:

    java myprogram

    but how do I run that same .class file if its in c:\myJavaProgram folder

    by the way, when I compiled the .java file, I had to use a .jar file, basically this was my command line:

    javac -cp "C:\Program Files\Java\jdk1.5.0_05\bin\stuff.jar" myprogram.java
    Last edited by benmartin101; Oct 27th, 2005 at 04:32 PM.

  2. #2
    Fanatic Member x-ice's Avatar
    Join Date
    Mar 2004
    Location
    UK
    Posts
    671

    Re: problem running java program

    Quote Originally Posted by benmartin101
    i can run my java program if the .class(which is the main) is in the bin directory of java. I just type:

    java myprogram

    but how do I run that same .class file if its in c:\myJavaProgram folder
    you have to change the path which does looks in for the java.exe file. Do it like this (type this in DOS before executing your program):

    path=%path%C:\myJavaProgram

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,168

    Re: problem running java program

    what do I type after that?

    with the command:

    java ... <- what comes after?

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,168

    Re: problem running java program

    is there another way just from the java.exe command?

    without having to type path=%....

  5. #5
    Fanatic Member x-ice's Avatar
    Join Date
    Mar 2004
    Location
    UK
    Posts
    671

    Re: problem running java program

    Quote Originally Posted by benmartin101
    is there another way just from the java.exe command?

    without having to type path=%....
    No, dos cant execute java.exe unless it knows where to look for it. Doing path=..... tells dos where to look for java.exe

  6. #6
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: problem running java program

    You can always set the classpath in your environment variables.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2005
    Posts
    1,168

    Re: problem running java program

    I wanted to do something like this to run the program:

    java -cp "C:\Program Files\Java\jdk1.5.0_05\bin\stuff.jar" C:\myJavaProgram\myprogram

    but it doesn't work. Shouldn't it work?

Posting Permissions

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



Click Here to Expand Forum to Full Width