在 Windows 中设置 java
所有,
我刚刚在我的机器上重新安装了 Java,因为我发现我有 2 个版本的 Java!无论如何,我已将环境变量 PATH 和 CLASSPATH 设置为 C:\Program Files\Java\jdk1.6.0_21\bin
。我在 C:\Temp
文件夹中编写了一个简单的 Java 文件,
package myPackage;
public class myClass
{
public static void main(String[] args)
{
System.out.println("Test");
}
}
编译此文件是否应该创建一个文件夹 myPackage
,其中类文件 myClass
将居住?
我的基本查询是我自己的包没有创建应该创建的文件夹结构。我猜环境变量有问题,但我不确定
All,
I have just reinstalled Java on my machine because I found I had 2 versions of Java !! Anyways, I have set up the environmental variables PATH and CLASSPATH to C:\Program Files\Java\jdk1.6.0_21\bin
. I have written a simple Java file in C:\Temp
folder
package myPackage;
public class myClass
{
public static void main(String[] args)
{
System.out.println("Test");
}
}
Should compiling this file not create a folder myPackage
within which the class file myClass
would reside?
My basic query is that my own packages are not creating the folder structure that should be created. I guess there is a problem with the Enviromental variables, but I am not sure
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要自己创建 myPackage 文件夹。将 myClass.java 文件放入 myPackage 文件夹中。然后编译。
You need to create the myPackage folder yourself. Put the myClass.java file in the myPackage folder. Then compile.
也许不是答案,但当我安装 JDK 时,我通常将 PATH 设置为 %PATH%;PATH_TO_JDK\bin (像你一样)和 JAVA_HOME=PATH_TO_JDK (不以 \bin 结尾)。它适用于我的大多数应用程序和开发环境。
Maybe not the answer, but when I install JDK, I usually set PATH to %PATH%;PATH_TO_JDK\bin (like you), and JAVA_HOME=PATH_TO_JDK (without ending \bin). It works for most of my application and development environment.
我认为你必须创建文件夹结构,java不会为你创建它。
I think you has to create the folder structure, the java will not make that for you.