How do I build ant's build.xml using NetBeans? - java

I've downloaded sources of one application using Subversion repository, but it turned out, that those sources were not composed to a NetBeans project. It was said in the manual, that I can build it using Apache Ant. I know, that NetBeans supports Ant by default. So here is the question - how can I tell NetBeans to run it's Ant on a specified build.xml?

File -> New Project
Then in Categories pick Java and then in Projects select Java Free-Form Project and hit Next. After that you will configure the project by selecting the location of the project the and build.xml and then associate targets in the build.xml with actions in the IDE.

Related

The project uses build.properties from another NetBeans installation

When using trying to build a NetBeans project created with a previous version, I get the following confirmation dialog:
Build Project
The project ... uses build.properties from another NetBeans installation.
Build Anyway
Use this installation
Update
What would these options do?
No matter which options I choose, I do not notice any difference in the build process.
Using NetBeans Development with projects created on NetBeans 8.1.
it depends on what type of dependencies you are using in your project, to be on safe side , I'd prefer clicking Update which it'll update current project's build properties with the external one,
also here's what (wiki.netbeans.org) have about build.properties file:
"If you edit build.xml by hand, you can of course arrange to build other projects (or any Ant scripts) as part of your build, using the or tasks. Note that a build-impl.xml, when building a foreign project, calls its build.xml (rather than skipping to its build-impl.xml), so you can freely mix a hand-customized project with IDE-customized projects."
thanks

Eclipse - always autogenerate Ant build files

When I create a project in Eclipse, I have to manually export the Ant build files to be able to build from command line easily.
Is there any way to make Eclipse generate the Ant build files when creating the project without further interaction?
With standard Eclipse it's possible to generate ant build files (Right click on the project -> Export -> Ant build file) but you need external plugins to generate them automatically (Web Tools Platform if I recall correctly).

what is the difference between maven-archetype-webapp and eclipse dynamic web project

why do I need to apply: mvn eclipse:eclipse command?
are they equivalent to application container/server?
Is there a file for which customizing is necessary besides web.xml?
when you create a web project using maven, like maven-archetype-webapp. It creates the folder structure as recommend by Maven for a webapp like shown here .
Now when you try to import these folders in Eclipse, it still would look like folders but eclipse cannot understand the nature of these folders. Eclipse relates folders and contents within them to an Eclipse dynamic web project only through its .project , .settings files
So in order for your maven project to be understood by Eclipse, you run the goal mvn eclipse:eclipse. After executing this goal, maven generates the .project, .settings files necessary for eclipse to understand the project as Web project.
This is however optional. You can still import the project as Maven projects within eclipse and continue to use them but you cant rely on Eclipse's features like clean/ build / build automatically.
Though I use eclipse, I dont rely on Eclipse's build feature. I have installed Maven eclipse plugin and that allows me to run maven goals and commands within Eclipse which is as good as running Eclipse's build feature. Hope this helps.

Create Eclipse java project with a java programm

I would like to generate Eclipse Java Project with my Java program. When I click a button: it will generate an eclipse project with the parameters I specified (source path, library, ...)
My questions are:
is there a way to do that ? and how ? (api).
it is possible to generate Net-beans project too ?
Best regards,
Florent
Maven enables this and many more things around creating, bulding, testing and developing Java projects.
Create a Java project from command line. Then, using Maven create NetBeans, Eclipse or IntelliJ IDEA specific project files. Or even easier, just import already created Maven project directly from these IDEs.
Create Java Project in Eclipse first. Then look into directory created. You should find there two files: .project and .classpath. These are the files you should create in your app to get what you want.
Also for eclipse available M2Eclipse plugin to provide some Maven feature from Eclipse IDE.
http://m2eclipse.sonatype.org/
While Maven is the way to go in the long term, the best way to start a project in Eclipse is:
Hit Ctrl+N and choose Java project
Fill in the project name fields
Copy your files from wherever they are to the newly created project (ensuring to preserve package hierarchy)
Refresh project from File menu
Create a Run / Debug profile to run your app.
It should be fairly simple to get up and running this way.
The reason people recommend Maven is because Eclipse is an IDE. It's great for development but its no good for resolving external dependencies or for command line / automated builds. Maven is an IDE neutral way of building and becomes essential the more dependencies a project pulls in.
Unfortunately Eclipse integration with Maven is pretty clumsy and can be summarized with these very broad steps:
Install Eclipse Helios
Install m2eclipse from the Help | Eclipse Marketplace
Mess around with eclipse.ini to make Eclipse start from a JDK.
Configure m2eclipse to use any existing Maven local repository
Hit Ctrl+N and create a new Maven project and skip archetype selection
Copy all the source files from the old project into the new ensuring to use Maven's conventions for file locations. (e.g. source goes in src/main/java)
Create a Run / Debug maven target to clean / install the app
I say broad steps because there are a lot of gotchas. For example if the source is Java 5+ you might have to tweak the pom to set the compiler level. Best to get Eclipse working and then worry about Maven.
Netbeans has vastly better out of the box support for Maven although IMO Eclipse is still the better IDE for other reasons.

How to distribute java project built in Eclipse?

Till now, I have been using Netbeans IDE for Java Applications. To distribute applications made in Netbeans, I just click on clean and build and it packs the application in .jar file which resides in a dist directory.
Now I have made a java project in Eclipse. Is Eclipse has any functionality similar to clean and build functionality of Netbeans by which we can pack java applications to distribute them.
You can right-click the project, select Export and choose Java, then JAR as the format.
File -> Export...
And choose Java -> JAR File. You will get a wizard to export any of your projects
Yes it has a clean and build functionality.
clean which clean all the developed a classes from the specified location
build which builds the class files at the same specified location respectively.
To distribute a project as a jar then you have to right click on the project and select export and in that select as jar.
Eclipse has a function to export the whole thing as a exetutable jar. It is under file>export.

Categories