【问题标题】:Java Path setupJava 路径设置
【发布时间】:2016-05-24 09:10:08
【问题描述】:

我正在尝试在我的 PC 上设置 java,但遇到了问题。我相信这些问题与正确配置路径有关。

目前,如果我在我的 cmd 行中运行 java,我会得到以下信息:

用法:java [-options] 类 [args...] (执行一个类) 或 java [-options] -jar jarfile [args...] (执行一个jar文件) 其中选项包括: -d32 使用 32 位数据模型(如果可用) -d64 使用 64 位数据模型(如果可用) -client 选择“客户端”VM -server 选择“服务器”VM 默认虚拟机是客户端。

-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
              A ; separated list of directories, JAR archives,
              and ZIP archives to search for class files.
-D<name>=<value>
              set a system property
-verbose:[class|gc|jni]
              enable verbose output
-version      print product version and exit
-version:<value>
              Warning: this feature is deprecated and will be removed
              in a future release.
              require the specified version to run
-showversion  print product version and continue
-jre-restrict-search | -no-jre-restrict-search
              Warning: this feature is deprecated and will be removed
              in a future release.
              include/exclude user private JREs in the version search
-? -help      print this help message
-X            print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
              enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
              disable assertions with specified granularity
-esa | -enablesystemassertions
              enable system assertions
-dsa | -disablesystemassertions
              disable system assertions
-agentlib:<libname>[=<options>]
              load native agent library <libname>, e.g. -agentlib:hprof
              see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
              load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
              load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
              show splash screen with specified image

更多详情请见http://www.oracle.com/technetwork/java/javase/documentation/index.html

但是,当我尝试运行 javac 时,我得到以下信息:

bash: javac: 找不到命令

我尝试按照 youtube 上的视频设置路径,但似乎没有帮助。

任何建议将不胜感激。

提前谢谢你。

【问题讨论】:

  • 你安装的是 JDK 还是只安装了 JRE?
  • 你不需要 git bash 来运行 Java
  • 您需要javac 的JDK。除此之外,java 的输出看起来还不错。您需要指定类的名称(例如java --classpath=/path/to/.class/files MyClass)或 JAR(例如 java -jar /path/to/app.jar`)。

标签: java git-bash


【解决方案1】:

您是想在系统上简单地安装 java 来运行程序,还是想编写和执行代码?如果您只想为程序安装它,java 网站上有所有用于安装 java 以在您的系统上运行的下载。对于编写代码,我推荐 DrJava,这是一个相对容易使用的开发环境,并且具有许多功能,一旦您学习并需要它们,就可以提供强大的编码能力。如果我了解您要做什么,我希望这会有所帮助。

【讨论】:

    【解决方案2】:

    首先在您的系统中安装JDK

    执行以下操作后

    1)。我的电脑->右键->属性

    2)。左侧高级系统设置

    3)。点击环境变量

    4)。在系统名称的用户变量中点击新建

    5)。变量名:- PATH

    Value:- **YOUR JDK PATH UPTO BIN FOLDER** , AT END ";"
    

    示例:- C:\Program Files\Java\jdk1.8.0_45\bin;

    然后在cmd中输入JAVAJAVAC

    【讨论】:

    • 好答案。 @kderrick 一条建议:确保不要搞砸 PATH 的其余部分。不要删除/重置 PATH。只需向现有的值添加一个新值,否则使用 PATH 的其他程序将无法添加。
    • 谢谢@AshwinGupta 我提到点击新变量
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-20
    • 2016-07-13
    • 1970-01-01
    • 2017-06-02
    • 2014-03-22
    • 2013-04-17
    • 2013-04-14
    相关资源
    最近更新 更多