在Sublime Text中编译和运行Java代码2 [英] Compiling and Running Java Code in Sublime Text 2

查看:194
本文介绍了在Sublime Text中编译和运行Java代码2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Sublime Text 2中编译和运行Java代码。不要只是告诉我在命令提示符中手动执行。谁能告诉我怎么样?

I am trying to compile and run Java code in Sublime Text 2. Don't just tell me to do it manually in the Command Prompt. Can anyone tell me how?

Btw,我在Windows 7 ...

Btw, I am on Windows 7...

推荐答案

如果您没有引用正确的文件夹,那么您的路径可能不起作用 - 通过步骤I设置的路径只能应用于该版本的JDK。

Your path might not appear to work if you haven't referenced the correct folder - that set by step I posted way back only applied for that version of the JDK.

如果您在右键单击计算机时没有看到任何菜单,请改为尝试。

If you aren't seeing any menu when you right click on 'Computer' try this instead.

对于JDK版本jdk1.7.0_07


  • 点击START
  • 在搜索区域中输入路径(不含引号)
  • 您应该看到为您的帐户编辑环境变量 <---点击此

  • 窗口应显示为环境变量


    • 单击TEMP

    • 选择路径,然后点击修改...

    • Click START
    • Type "Path" (without the quotes) into the search area
    • You should see "Edit environment variables for your account" <--- click this
    • A window should appear titled "Environment Variables"
      • Click TEMP on the top area
      • Scroll a little bit on the bottom second area until you find Path
      • Select Path and click Edit...

      ; C:\程序文件\Java\jdk1.7.0_07\bin




      • 确保两个窗口中都有OK

      • 如果需要,请重新启动Sublime文本

      • 有了它。

        因此,要在完成上述操作后真正获得编译和运行Java程序,您需要执行以下操作。只需创建一个简单的java类,以便与我在同一页面。

        So to actually get compiling and running your Java programs after completing the above, you will need to do the following. Just create a simple java class so you are on the same page as me


        • 打开一个新的SublimeText2文档并粘贴以下

        • Open a new SublimeText2 document and paste the following

        class hello {
            public static void main(String[] args) {
                System.out.println("Hello World!");
            }
        }
        


      • 然后将该文件保存到桌面 - 调用它

      • Then save that file to your Desktop - call it

        hello.java
        


      • 您应该有这样的

      • you should have something like this

        现在,您可以在键盘上按 Ctrl + b 来构建您的Java类,

        Now press Ctrl+b on your keyboard to build your java class which should produce this!


        • 您需要打开命令提示符窗口,所以请继续操作。

        • 然后导航到您的java类所在的文件夹(在本例中为我们的桌面)

        • 使用命令提示符导航很容易 - 只需使用

        • You need to open a command prompt window, so go ahead and do that.
        • Then navigate to the folder (in this case our desktop) where your java class is located
        • navigating using the command prompt is easy - just use

        cd <-- this stands for change directory
        dir <-- this will list everything in the current directory if you get stuck!
        


      • 在我的例子中,它看起来像这样


        • 酷,看起来我们在正确的地方。

        • 最后输入以下内容

        • Cool, looks like we are in the right place.
        • Finally type the following

        java hello
        


        我希望这可以帮助任何人绊倒这个!

        I hope this helps anyone who stumbles across this!

        这篇关于在Sublime Text中编译和运行Java代码2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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