How to set project classpath in Eclipse and NetBeans are similar: just right-click the project name, choose Properties to bring up the Properties Window. But there are some small variations between the two, mostly of the nature of ease-of-use, or style.

How to set classpath in NetBeans:

In NetBeans Project Properties Window, you click Libraries in the left panel, and in the right panel are 4 categories of classpath you can configure:
  • Compile: Empty by default. Compile-time libraries are automatically propagated to other categories of classpath, so you don't need to repeat the same set of jar files in all 4 categories.

  • Run: By default includes everything in compile-time classpath, and compiled classes (e.g., build/classes).

  • Compile Tests: By default includes everything in compile-time classpath, compiled classes (e.g., build/classes), and JUnit.

  • Run Tests: By default includes classpath for compiling tests, and compiled tests.
The separation of the 4 categories of classpath offers a great deal of flexibility, and in most cases, common-sense default values are used to save configuration efforts. Depending on project types, you may see fewer categories of classpath in NetBeans. For instance, there is no Run classpath for web application project, since we don't directly run a war file.

How to set classpath in Eclipse:

Eclipse manages run classpath and build/compile classpath in different places. To configure run classpath, go to menu Run | Run ... to open up the Run Dialog Window. Your current project should already be selected, otherwise, expand the Java Application node in the left panel and select it. Click Classpath tab in the right panel. The default classpath for the current project is the output folder where all compiled classes reside. You can then click any of these buttons to modify run classpath: Add Projects, Add JARS, Add External JARS, Advanced, etc.

To configure build classpath, in Eclipse Project Properties Window, click Java Build Path in the left panel, and in the right panel choose Libraries tab. There are more classpath-related elements in Eclipse: JARs, External JARS, Variables, Libraries, Class Folders, and other Projects. Click Add External JARs (not Add JARS) if you want to add a jar file to classpath, and click Add Class Folders if you want to add a directory or folder to classpath.

It seems to me Add Variables, Add Libraries, and Add JARS all add collections of classpath elements that are defined inside Eclipse, but I don't know their differences. When I specify classpath in any IDE, I like to explicitly spell out Jar files and directories, without using any IDE-specific artifacts. I suppose the whole purpose of having them is to reuse them in other projects, but I find it's pretty unrealistic due to various jar version differences.

I don't care about the difference between a jar file and a directory, both of them are just an element in the classpath. I like the fact that NetBeans combine them into one single Add JAR/Folder button.

When I create a project in Eclipse 3.2, the default output folder is set to the same folder as source folder, which is not a good idea. At least for me, I don't like mixing class files along with java source files. Wouldn't that also slow down classloading when JVM searches classes, since there are twice as many files to scan. You can change the output folder in project property window | Java Build Path.

7

View comments

When writing javadocs, IntelliJ automatically adds a closing tag for html elements. For instance, after typing <lt>, it automaticaly adds </lt>, or after typing <p>, it adds </p>. It can be annoying since simple html elements like those used in javadocs don't really need ending tags.
To disable javadoc automatic closing tags in IntelliJ, simply go to IntelliJ Preferences -> Editor -> Smart Keys, then on the right panel, uncheck Automatically insert closing tag.

Intellij 14 screenshot:


 Intellij 15 screenshot:

A related note, JDK 8 has tightened javadoc syntax check, and as a result self-closing elements like <p/>, or <br/> are deemed invalid and will cause failures. See JDK-8020619. However, this checking can be disabled by passing nonstandard option -Xdoclint:none to javadoc tool. For official javadoc guidelines, see How to Write Doc Comments for the Javadoc Tool .
0

Add a comment

Labels
Archive
Popular Posts
Popular Posts
  • Two JVM options are often used to tune JVM heap size: -Xmx for maximum heap size, and -Xms for initial heap size. Here are some common mi...
  • Simple enum . The ; after the last element is optional, when this is the end of enum definition. public enum Color { WHITE, BLACK, RED, ...
  • How to set project classpath in Eclipse and NetBeans are similar: just right-click the project name, choose Properties to bring up the Prope...
  • Let's say I need to spawn multiple threads to do the work, and continue to the next step only after all of them complete. I will need t...
  • This is a sample web.xml based on Servlet 2.5 (part of Java EE 5) that declares common elements. All top-level elements are optional, and c...
  • The default string value for java enum is its face value, or the element name. However, you can customize the string value by overriding toS...
  • Prior to JDK 6, we can check if a string is empty in 2 ways: if(s != null && s.length() == 0) if(("").equals(s)) Checking ...
  • When writing javadocs, IntelliJ automatically adds a closing tag for html elements. For instance, after typing <lt>, it automaticaly a...
  • StringBuilder was introduced in JDK 1.5. What's the difference between StringBuilder and StringBuffer? According to javadoc , StringBu...
  • With array, we can easily declare and initialize it at the same time: String[] favorites = new String[] {"EJB", "JPA", ...
Loading