Results 1 to 2 of 2
  1. #1
    Moncleared is offline Member
    Join Date
    Jan 2009
    Rep Power

    Default System ClassPath and compiler question


    So my system is apparently using an extremely old version of java, something like 1.3.1 or some sort. I have a few questions.

    1. I am using Windows XP and would like to know how the command prompt knows that when I type java and javac where to go to find those applications. I understand that the answer is most likely going to be in System ---> Environmental Variables.

    2. Assuming that I do NOT change the Environmental Variable, when I java <class name> a file, how can I appropriately tell it to use all the information in C:/Program Files/Java/jre6 (most updated java).

    I believe the answer is by using -classpath <above url here>

    My problem is that when I use Eclipse on my machine to create applications Eclipse does fine compiling and running the application. However, when I try to compile and run them on my command prompt on my system I get errors such as method not found. So, I am trying to figure out all my alternatives to fixing the problem. This problem will be a wide problem on multiple machines that will use the classfile, so I was hoping I could create a bat or cmd file that would set the correct classpath.

    I would appreciate examples if anyone can.

    I've tried doing the following and it failed:

    java -classpath "C:\Program Files\Java\jre6\bin\*.jar" className

    The above was my attempt to say, use all of the new source/code from jre6. However, it is not working.

    Thanks in advance.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Colombo, Sri Lanka
    Blog Entries
    Rep Power


    First of all why you are still working on such a old version, you've misses lots of new features.

    To use all the java functionality you must set the class path first of all. You can do it in many ways, either in permanent or temporary way.

    First way is to set the path in environment variables in your system. This is really good, you need to worry next time once you set the path.

    If you are keen with autoexec.bat system file you can set the classpath is there too. But it's bit risky if you don't know exactly how to do that. I use this setup in my PC for command prompt testings and stuff. On IDEs we can easily link the installation path. But I'm not going to give any advice on this.

    The other way is bit mess, temporary way. In each time you close and open the command prompt need to do that. Change the command prompt working path to your source file (*.java) included folder. Then type the following command, assume that your Java installation in C:\Prgrame Files\Java\JDK1.6\

    Java Code:
    path=c:\Program Files\Java\JDK1.6\bin
    and press enter. Nothing is happen actually, so to make sure type javac If the everything is fine then you setup the path correctly.

    Hope it's helpful to you.

Similar Threads

  1. Compiler in Apple system ..!!
    By ŖΫ ỏ Ңόρę in forum New To Java
    Replies: 5
    Last Post: 01-18-2010, 07:46 PM
  2. Compiler Question
    By SamuelM in forum New To Java
    Replies: 2
    Last Post: 12-13-2009, 03:06 PM
  3. How to set ClassPath?
    By kishan in forum Advanced Java
    Replies: 5
    Last Post: 12-11-2009, 07:24 AM
  4. Question about
    By suvojit168 in forum New To Java
    Replies: 3
    Last Post: 07-26-2009, 03:01 AM
  5. compiler,JIT compiler & interpreter
    By gamilah in forum New To Java
    Replies: 4
    Last Post: 11-04-2008, 12:32 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