你如何安装JDK? [英] How do you install JDK?

查看:81
本文介绍了你如何安装JDK?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有eclipse,我可以测试运行java应用程序,但我不知道如何编译它们。我读到我应该将javac -version输入到我的cmd.exe中,看看它是否被识别。不是这样。所以我去了sun的网站下载/安装了JDK v6。然而,它仍然说javac是一个无法识别的命令。我做错了什么?



谢谢!



更新
在阅读一些回复之后,好像我想要做的是创建一个可以在另一台计算机(运行时)上运行的.jar文件。但是,我无法确定如何做到这一点。这可能是因为我使用Flex Builder(eclipse),但是我也添加了创建java项目的能力。



谢谢



更新
OK我不想制作一个JAR文件,我不是想要归档它...制作程序的全部要发送给用户,所以他们可以使用程序...这是我想要做的...为什么这么难?

解决方案

当您将项目导出为Eclipse中的JAR文件(如Michael Borgwardt指出),JAR文件可以作为可执行文件,您可以指定什么是可执行类,这意味着哪一个具有入口点[aka public static void main(String [] args)]



如果用户安装了JRE,他/她可以双击它将被执行。



编辑: 有关如何工作的详细说明,请参阅如何创建可执行Java程序?


I have eclipse and I can test run java apps but I am not sure how to compile them. I read that I should type javac -version into my cmd.exe and see if it is recognized. It is not. So I went to sun's website and downloaded/installed JDK v6. Yet it still says 'javac' is an unrecognized command. What am I doing wrong?

Thanks!

UPDATE OK after reading some replies it seems like what I am trying to do is create a .jar file that can be ran on another computer (with the runtime). However I am having trouble figuring out how to do that. This might be because I am using Flex Builder(eclipse), but I added the ability to create java projects as well.

Thanks

UPDATE OK I do not want to make a JAR file, I am not trying to archive it...the whole point of making a program is to send it to users so they can use the program...THAT is what I am trying to do...why is this so hard?

解决方案

A JAR file can function as an executable, when you export your project as a JAR file in Eclipse (as Michael Borgwardt pointed out) you can specify what's the executable class, that meaning which one has the entry point [aka public static void main(String[] args)]

If the user installed the JRE he/she can double-click it and the application would be executed.

EDIT: For a detailed explanation of how this works, see the "How do I create executable Java program?"

这篇关于你如何安装JDK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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