How to Make a Classpath Variable

Object-based programming languages like Java create objects with defined behaviors and states. Objects model the real-world objects that the program seeks to emulate. Classes define groups of similar objects and dictate how objects are created. Languages like Java include packages of predefined classes for programmers; however, developers may need to create and use their own classes for a specific program. Developers can call up their custom classes using the classpath command. Learning how to make a classpath variable allows you to access your user-defined classes.

Instructions

    • 1

      Save the user-defined class files in either a folder or as a compressed (.zip or .jar) file.

    • 2

      Open a command line terminal, such as "cmd.exe" in Windows. Set the directory to the hard drive on which the program is stored, such as "C:>."

    • 3

      Enter the command "set CLASSPATH=" without quotation marks followed by the exact directory the class is in. Specify the exact location if the class is saved as a compressed file. For example, "C:>directory/classes" if the class files are uncompressed or "C:>directory/classes/class.jar" if they are compressed.

    • 4

      Type "set CLASSPATH=" without quotation marks to clear the classpath.

EduJourney © www.0685.com All Rights Reserved