score:-1

The following link may be of assistance http://netbeans.dzone.com/articles/importexport-code-formatting it talks about sharing sharing settings.

score:0

It should be easy to use Eclipse's formatter as a plugin in Netbeas, like it was done for IntelliJ

score:1

It would appear that, as of Netbeans 7.3.1, a very clever fellow developed a Netbeans plugin that accepts Eclipse Formatter XML files. I have not tested this yet TBH, but I will be doing so in the very near future (as I am the only one at the office that prefers Netbeans over Eclipse, and I think my co-workers are conspiring to kill me due to git merge conflicts).

https://blogs.oracle.com/geertjan/entry/eclipse_formatter_for_netbeans_ide

score:2

I like NetBeans very much, but have the same problem with formatting. I've found this maven plugin http://mvneclipsefmt.sourceforge.net/usage.html Seems it can run eclipse formatter as maven goal. But I didn't try it yet.

score:2

There is a post on JBoss community which seems to address formating issues, it might be of some help; http://community.jboss.org/wiki/ImportFormattingRules

score:2

You can use "Eclipse Code Formatter for Java" NetBeans plugin it works with NetBeans 7.3 and .7.4 (but with a little problem!).

score:5

AFAIK There is no way to import the Eclipse formatting preferences into NetBeans. But if you use Maven you can use the Maven2 Java Formatter Plugin which uses the Eclipse JDT features to format source files and integrates nicely with Maven projects. For a usage of current version 0.3.1 see here.

This is a simple pom.xml using the formatter. Just put in any Java source file and run mvn java-formatter:format, your source should be formatted using the given Eclipse configuration file (where you have to provide the path to your own one).

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>de.mackaz</groupId>
    <artifactId>maven.java.formatter.plugin.example</artifactId>
    <version>0.1</version>
    <packaging>jar</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>com.googlecode.maven-java-formatter-plugin</groupId>
                <artifactId>maven-java-formatter-plugin</artifactId>
                <version>0.3.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>format</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                <configFile>./example-eclipse-code-format-config.xml</configFile>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

EDIT:

A different approach is to invoke the Eclipse Code Formatter from commandline, (but takes a bit longer and is not nicely integrated into the Maven lifecycle), as described here. You can format a sourcefile with it like this:

/opt/eclipse/eclipse -application org.eclipse.jdt.core.JavaCodeFormatter -verbose -nosplash -config example-eclipse-code-format-config.xml src/main/java/de/mackaz/FormatMe.java

(Also take a look at this page where the author put that into a little script)

It should be easy to integrate one of those approaches into NetBeans. Either wrap those inside an Ant file and add that to your NetBeans commands, or write a little NetBeans plugin to add the action e.g. to the contextmenu (which is pretty easy, especially compared to writing Eclipse Plugins).

score:6

The answer is YES. You can use eclipse code formatter in Netbeans, and enjoy using Netbeans. You need to download eclipse code formatter plugin from below location suitable to your Netbeans version, import your existing eclipse code formatter and ready to go

http://plugins.netbeans.org/plugin/50877/eclipse-code-formatter-for-java


Related Query

More Query from same tag