使用Notepad ++编译Java代码 [英] Using Notepad++ to compile Java code

查看:154
本文介绍了使用Notepad ++编译Java代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试将Notepad ++设置为一个小Java环境,主要用于学习Java,因为我在使用NetBeans时遇到一个简单的程序有些困难,遗憾的是有关设置Notepad ++以调用Java代码的所有建议没有工作。

I've been trying to set up Notepad++ as a little Java environment, mainly for learning Java as I was having some difficulty getting a simple program to work with NetBeans, unfortunately all the advice on setting up Notepad++ to call the Java code is not working.

我想notepad ++已经改变或Java开发工具包已被大量修改,因为我使用的所有示例都会导致错误,即使几乎没有空间错误。

I guess notepad++ has changed or the Java development Kit has been massively modified because all examples I have used result in errors, even though there is little room for error.

开始我发现这个网站:
http://blog.sanaulla.info/2008/07/25/using-notepad-to-compile-and-run- java-programs /

to begin I found this site: http://blog.sanaulla.info/2008/07/25/using-notepad-to-compile-and-run-java-programs/

这是运行Javac编译代码的代码:

this is the code to run Javac to compile the code:

javac "$(FILE_NAME)"

java "$(NAME_PART)"

运行生成的字节代码,但是如何这完全没有成功。 Java已正确设置,我可以通过CMD调用Java程序来完成它。

to run the resulted byte code, however this has absolutely no success at all anymore. Java is properly setup and I can call the Java program to do its thing through CMD.

使用名为npp的插件并通过F6调用并使用此代码运行(在注释)成功地将Java程序编译成正确的.class文件,但命令在运行程序时失败

Using a plugin called npp and called through F6 and run with this code (given in the comments) succeeds in compiling the Java program into the correct .class file, however the command failed in running the program

cd "$(CURRENT_DIRECTORY)"
javac $(FILE_NAME)
java $(NAME_PART)

Notepad ++中控制台的错误是:

errors from the console in Notepad++ are:

java.lang.NoClassDefFoundError: first
Caused by: java.lang.ClassNotFoundException: first
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: first.  Program will exit.
Exception in thread "main"

我想设置Notepad ++来编译和运行代码这将是简单而有趣的,但它似乎互联网上的所有文档都已过时,因为没有任何作用。

I figured setting up Notepad++ to compile and run the code would be easy and fun, but its seems all documentation on the internet is outdated as nothing works.

我想从Notepad ++中编写和运行Java代码的简单方法

I would like a easy way to compile and run Java code from within Notepad++

我可以使用CMD,但我更愿意将它集成到记事本++中

I could just used CMD but i'd rather it be more integrated into notepad++

感谢任何可能的救命。欢呼:)

Thanks for any possible help. cheers :)

编辑:我正在使用最新版本的Java,记事本++并拥有Windows 7

I'm using the latest version of Java, notepad++ and have Windows 7

编辑2:代码:

 //A Very Simple Example
 class ExampleProgram {

   public static void main(String[] args){

        System.out.println("I'm a Simple Program");
   }
 }


推荐答案

与Eclipse或Netbeans等IDE相关联的学习曲线最初主要涉及您上面已有的内容 - 设置类路径,环境变量等知识。而不是Notepad ++(我喜欢它,但它不是为Java制作的),我建议使用Eclipse,特别是如果你有一台可怕的PC(它有点内存饥饿)。除了设置路径之外,之后你就可以开始摇滚了。

The 'learning curve' associated with IDEs like Eclipse or Netbeans initially mostly involves what you already have above - knowledge of setting class paths, environment variables and so on. Instead of Notepad++ (which I love, but it's not 'made' for Java), I'd recommend Eclipse especially if you have a grunty PC (it's a bit memory hungry). Aside from getting the paths setup, after that you'll be ready to rock.

Eclipse正在积极开放地开发,是目前记录最多的IDE之一。教程必须正确地工作:)。但说真的,这很不错。然后当你想用Java或其他类型的Java编程扩展到Android开发时,你只需要加载所需的加载项,你就会大笑。它还支持调试,Notepad ++当然无法与之竞争。

And Eclipse being actively and openly developed is one of the most documented IDEs out there. The tutorials are bound to work correctly for it :). But seriously, it's pretty good. And then when you want to expand to Android development in Java, or some other type of Java programming, you just load up the add-ins required, and you're away laughing. It also supports debugging, the likes of which Notepad++ certainly cannot compete.

这篇关于使用Notepad ++编译Java代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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