简体   繁体   English

无法编译Eclipse中的任何Java代码

[英]Trouble compiling any java code in Eclipse

I'm new to the world of java and have been following a few online tutorials to get started. 我是java世界的新手,并且已经开始关注一些在线教程。 Everything was going great and the programs were compiling perfectly and then all of a sudden, without me seemingly changing anything, as far as preferences directly attributing to Eclipse, it stopped compiling any code at all. 一切都很顺利,程序完美编译然后突然间,没有我似乎在改变任何东西,就直接归因于Eclipse的偏好而言,它根本不再编译任何代码。 Even the simple Hello World code will not compile. 即使是简单的Hello World代码也无法编译。 All I get in the console line for any code is: 我在控制台行中获取的任何代码都是:

Usage: javaw [-options] class [args...]
       (to execute a class)
or  javaw [-options] -jar jarfile [args...]
       (to execute a jar file)
where options include:
-d32      use a 32-bit data model if available
-d64      use a 64-bit data model if available
-server   to select the "server" VM
-hotspot      is a synonym for the "server" VM  [deprecated]
              The default VM is server.

-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>
              require the specified version to run
-showversion  print product version and continue
-jre-restrict-search | -no-jre-restrict-search
              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

See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details. 有关更多详细信息,请参阅http://www.oracle.com/technetwork/java/javase/documentation/index.html

I'm not exactly sure of what this is or why it started doing it. 我不确定这是什么或为什么它开始这样做。 How do I go about in fixing the compiler so I can continue to learn? 我如何修复编译器以便继续学习?

That happens because you haven't installed JDK but only JRE. 发生这种情况是因为您没有安装JDK而只安装了JRE。 Install JDK to make it work. 安装JDK以使其工作。

Source 资源

I too have had this problem. 我也遇到过这个问题。 Try restarting Eclipse. 尝试重新启动Eclipse。 If that doesn't work, restart your computer. 如果这不起作用,请重新启动计算机。 If even that doesn't work, re-install Java. 如果即使这样也不起作用,请重新安装Java。 Its an annoying bug that usually occurs when your computer goes into standby while a program is running on Eclipse. 当程序在Eclipse上运行时,计算机进入待机状态时,通常会出现这种烦人的错误。

EDIT: If the problem persists, you can make a small javac program that would compile any code in a given directory. 编辑:如果问题仍然存在,你可以制作一个小的javac程序,编译给定目录中的任何代码。

Hope I helped! 希望我帮忙!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM