什么是Java类路径和路径? [英] What are Java Classpath and Path?

查看:216
本文介绍了什么是Java类路径和路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在四处搜寻,试图了解什么是Java Classpath和Path。但是,我不确定我是否理解。如果觉得这个话题是这些灰色领域之一。



有人可以向我解释一下这是什么吗?我的意思是,我在哪里找到并设置它们(Mac / Windows上的实际文本文件在哪里)?每个实例只有一个实例吗?如果是这样,如何设置多个类的路径?



您可能已经注意到,在阅读了许多不同的教程之后,我现在完全感到困惑。现在,我真的很想直接解释。



请帮助我,我只是想学习:)
谢谢大家

解决方案

路径只是文件夹位置。 路径是您的操作系统默认查找程序的位置。如果 java javac javap 等,等等,在您的路径中,则只需输入它们的名称即可,而无需整个文件夹位置。



您的 classpath 与此相似。它是一组文件夹,包含描述类(因此称为名称)和.jar文件的.class文件,这些文件基本上是包含 .class文件的文件。您正在运行的所有代码都是在类路径之外(生成的)或在Java库之外(在技术上也是类路径的一部分)。



每次运行您可以通过传递给 java 可执行文件的参数来指定Java程序的类路径。它还从扩展文件夹中获取类,保留Java用作系统类路径的特殊文件夹,最后保留引导程序类,这是几乎所有Java程序都需要运行的一组重要类。 p>

I have been googling around, trying to understand what the Java Classpath and Path are. However, I am stil not quite sure if I have understood it or not. If feel that this topic is one of those grey areas.

Can someone explain me what those are? I mean, where do I find and set them (where is the actual text file on Mac/Windows)? Is there only one instance of each one? If so, how do I set the path for multiple classes?

As you might have notices, I am totally confused right now after reading so many different tutorials... So now I really would like to have a straight forward explanation.

Please help me, I just trying to learn :) Thank you all

解决方案

A path is just a folder location. The path is where your OS will look for programs by default. If java, javac, javap, etc, etc, are in your path then you can just type their names without the entire folder location.

Your classpath is similar. It is a set of folders that contain .class files describing classes(hence the name) and .jar files, which are basically files that contain .class files. All code that you're running is either out of the classpath, generated, or out of the java libaries(also part of the classpath, techncically).

With each run of a java program you can specify a classpath by parameters passed to the java executable. It also grabs classes out of "extension folders,", special folders Java keeps around to act as a system classpath, and finally, the "bootstrap classes", which are a set of important classes almost any Java program needs to run.

这篇关于什么是Java类路径和路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆