如何只使用JRE就可以编译和运行没有JDK的java程序? [英] How can I able to compile and run java programs without JDK with just JRE?

查看:945
本文介绍了如何只使用JRE就可以编译和运行没有JDK的java程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的机器上安装了JRE并下载了Eclipse IDE并开始在该IDE上工作。

I have installed JRE in my machine and downloaded Eclipse IDE and started to work on that IDE.

我从一些博客中读过如没有JDK我们不能编译java程序,但我能够在eclipse IDE中运行程序/应用程序。

I have read from some blogs like Without JDK we can't compile the java program but i can able to run program/application in eclipse IDE.

然后在其他一些博客中给我提供的信息,比如eclipse会有自己的JDK所以试试运行在命令提示符下获取已知信息。当我尝试通过命令提示符编译bin文件夹(C:\Program Files \ Java @\\jre7 \ bin)中的程序时,它说javac无法识别。我认为这是因为编译的类文件丢失,因为没有安装JDK所以我从Eclipse IDE中复制了带有类文件的项目,并尝试运行它说无法找到的程序或加载主类filename.java。

Then in some other blogs gave me information like eclipse will have own JDK so try to run in command prompt to get know information. When i try to compile the program in bin folder(C:\Program Files\Java\jre7\bin) via command prompt it says javac couldn't recognize. I thought it's because of compiled class file is missing as JDK is not installed so i have copied the project from Eclipse IDE with class file and try to run the program it says couldn't find or load main class filename.java.

即使我已将环境变量设置为JRE bin路径的Java_home。

Even i have set environment variable as Java_home for the JRE bin path.

请简要解释JDK和JRE的差异我。

Pls explain JDK and JRE difference in brief to me.

推荐答案

我现在理解这个概念。

申请表是即使没有安装JDK也可以在eclipse中运行,因为eclipse在我的机器上安装了自己的编译器和JRE。

Application is running in eclipse even without JDK installation as eclipse has its own compiler and JRE installed in my machine.

Eclipse IDE中带有类文件的项目副本抛出的错误就像'couldn找不到或加载主类filename.java'因为运行时环境找不到类文件作为Javac编译器而Eclipse编译器类会有所不同所以内容会有所不同。所以java解释器找不到eclipse编译器类文件的类文件(类似于序列化概念)。

Copy of project from Eclipse IDE with class file is throwing error like 'couldn't find or load main class filename.java' because runtime environment couldn't find the class file as Javac compiler and Eclipse compiler class will be different so content will be different. So java interpreter couldn't find the class file of eclipse compiler class file(As similar to serialization concept).

这篇关于如何只使用JRE就可以编译和运行没有JDK的java程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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