How can I open non-Netbeans Java project using Netbeans? - java

I'm using Netbeans for my Java development, and every time I download a project that has been developed using other IDE, I can't run the project because of errors.
Is there any way to open regular people's projects easily without headache.
Note : the project am trying to open is not an Eclipse project, so I can't use the Eclipse importer.
And usually what are Java developers using for development?

Most Java developers are split between Eclipse , IntelliJ Idea and NetBeans. NetBeans is capable of opening Eclipse projects and Idea can export to Eclipse. So this should solve most problems.
Another way is to check if you project is using Maven or a similar model. Generally there are plugins for Netbeans that can handle import from this sort of sources.

I've had some luck using File > New Project… > Java > Java Project with Existing Sources, which "Imports an existing Java application into a standard IDE project. The Java application can have multiple source folders. Standard projects use an IDE-generated Ant build script to build, run, and debug your project." Conveniently, the generated script includes targets that can be overridden to alter the build process, as seen here.

We have several projects with existing ant build scripts and all I want is to have NetBeans as my code editor ...so far.
We aim for that the projects are independent of IDE as we have been used to just use emacs and ant for coding/building, which means that independant on platform you should be able to checkout the code and just build it no matter if it is within an IDE or just a shell/"DOS prompt". If you have projects like that use the "Java Free-Form project" and add all jars that you have defined in build script to also be included in Netbeans CLASSPATH.
This type of project will use your ant scripts for everything and will still work even if someone in your project prefer to use other coding environment.
Hope this can help

Related

Import Java Project from Eclipse to NetBeans [duplicate]

Is there a way to share the same *.java files between Netbeans and Eclipse?
You can import an eclipse project into netbeans,
or you can create an eclipse project from existing sources.
Sharing the Java source files is not the problem - just put them into some source control system, and then import them in both IDEs. Usually the configuration, especially the build process, is the main problem.
In practice, the solution is likely that you maintain separate project configuration files for both IDEs, but use a common build script (e.g. ant) that is supported by both. The project configuration allows you to use IDE-specific features, while the build script makes sure that both environments produce the same output.
Of course. eclipse supports linked source folders. The sources files don't have to be located in an eclipse project folder.
Inside an eclipse java project, select New -> Folder, then select "Advanced" and check "Link to alternate location" (eclipse 3.6, may be slightly different on other eclipse versions). "Browse" to choose the source folder from the netbeans project, press Finish.
Now you have linked (standard) folder to the Java files inside the netbeans project and modifying those files will modify them at the remote location.
Finally - right-click on this linked folder and choose Build Path -> Use as source folder.
(I leave the other way round to the netbeans experts)
In the ideal case you have your code stored in a version controlled repository (SVN, CVS, etc.). Then it is not as big of a factor whether you are using Eclipse or Netbeans.
This article, taken from a NetBeans 6.2 version of documentation, explains how you can import an Eclipse project into NetBeans and work with both together. NetBeans will create new project files but will link to the Eclipse source files, allowing sharing between the two. I have not tried this yet myself, but may be going down this path soon. After switching to NetBeans just this week, noticed that a significant feature in Eclipse is not in NetBeans - that of being able to create different run configurations that are not incorporated and stored into the POM. At this point in time, I do not have a solution to the run configuration issue, but if you do, please update the SO question here.

Google web toolkit with Netbeans?

I prefer to use Netbeans as my IDE rather than Eclipse. A few years ago when I looked into Google Web toolkit, there was no good Netbeans plugin for GWT and everyone suggested to use Eclipse. How is the situation now? Is there any better plugin on the market, or is Eclipse the best option?
I prefer Netbeans over Eclipse too. To develop for GWT, I used the following setup steps without installing gwt4nb plugin. Since I use an IDE for code analysis and editing help only, and feel quite comfortable manipulating files and directories in the source tree directly. Though this may not fit your case, I guess for many developers the steps should be good enough because you can treat gwt development just a normal java project.
Install JDK, NetBeans-SE. Extract gwt package. I have a note for gwt-1.7.1. If running on a windows 64bit version, install 64bit netbeans and jdk, and also a 32 bit JRE.
Copy the Hello sample from gwt directory to a directory out of gwt package directory. Create a project of existing java source code, and put the project under the same Hello directory. Then netbeans will create two files in the Hello directory: nbbuild.xml and manifest.mf, and create its own nbproject directory under Hello. I simply ignore these files.
In netbeans "Projects" window, right click on "Libraries" and choose "Add JAR" to add the jar files from the gwt directory.
In netbeans "Files" window (not the "Projects" window), you will see the original "build.xml" file that comes with the Hello sample. Edit this file so the "gwt.sdk" points to the location of gwt package directory. On windows 64bit, also add a "jvm" property under "java" task. It shall look like (only jvm=... is newly added):
<target name="hosted" depends="javac" description="Run hosted mode">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.HostedMode"
jvm="C:\\Users\\youhere\\Programs\\jre6.32\\bin\\java">
<classpath>
Use "Files" window, click to expand "build.xml" file node. Then right click on "hosted" ant target under "build.xml" and choose "Run Target" in the context menu to build and run the hosted mode.
The ant targets from "build.xml" you usually use:
"build": Use this to build the javascript.
"hosted": Use this to build java and start hosted server and browser.
Once the hosted server is started, you can run "build" target to build the javascript and to have the result served by the running hosted server immediately without restarting the server. Use your normal browser to see the javascript version at "localhost:8888". You can set a different port by editing the "build.xml" file.
Usually I copy the Hello sample to a different directory, and use that as a start point of a new project. After that manually edit the files to match the project naming and directory structure.
I also copy the other samples from gwt package to a new directory, then build and run them to use that as a code reference. If you want to also develop the servlet, take a look at the servlet of DynaTable sample and create or copy the files into the same directory structure in your project.
A note about gwt4nb plugin: I installed it but figured out it is too heavy weight for me. With the above manual setup, I can do everything that I need to without any difficulty.
I would say Eclipse is the best free option. Intellij IDEA (paid edition) has also good GWT support but it is not as good as Eclipse.
I think the only official support goes for eclipse, see here : https://developers.google.com/web-toolkit/download
Based on my personal experience, if you want to have a good integration between GWT and your IDE, go for Eclipse. If you intend to use Maven, I also suggest M2E http://m2eclipse.codehaus.org/
EDIT
Forgot to say the most important thing. Netbeans by the way, seems to have a nice support of GWT but I never tested, see : http://netbeans.org/kb/docs/web/quickstart-webapps-gwt.html
I am sure this is not the correct and suitable answer. But if you like to trade off, this is just an idea.
sudo -i
cd ~/gwt
./projectCreator -ant build -out projects/myapplication
./applicationCreator -out projects/myapplication myapplication.client.MyApp
Then, you can import the project ...
In Netbeans create a new projects and choose 'Java Project With
Existing Ant Script',
Set Location to the myapplication folder created earlier
Set Build Script to the build.ant.xml file created by projectCreator
Set Project Name to something more appropriate
Open the project properties and under Java Sources click Add Folder.
Select the projects/myapplication/src folder and press OK
Please excuse, if you didn't like this approach.
Sounds similar with Battle for Eclipse and Netbean but you are talking about concern with GWT.
So , I think you can choice as you more prefer depends on your experiences. You can do GWT developing in various IDE because I assume GWT runs on it's SDK not on IDE . But there has some points of views. Example : easy to generate , test , develop ..etc on each IDE.
I also personally love NetBean due to beautiful GUI :) . But I am working with Eclipse IDE because our team has been developed and configured on it for a long time so we have hard to change IDE (sometimes very hard to change Eclipse version because we can't imagine new version will more reliable for our projects).But I don't mean Eclipse is the best option , as I described you may configure your GWT projects on any other IDE also as your experiences via GWT SDK.
"...and everyone suggested to use Eclipse." . Yes you will see most of sample projects for it were figured with Eclipse IDE. Only aspect for GWT , I think you have chance to choose NetBean IDE without any worries.
You can develop GWT project on NetBean IDE as follow...
1.) First off, download and install the gwt4nb plugin. ( you may have exp for install plugin on NetBean IDE )
2.) download GWT SDK and extract it to your specific location.
3.) create a new Java Web –> Web Application. Name your application and hit Next until you get to the Frameworks tab. If you have successfully installed the gwt4nb plugin you should see Google Web Toolkit listed. Select the Google Web Toolkit framework.
4.) Next, browse to the GWT SDK installation folder. Name your GWT module and hit Finish.
5.) Clean and Build your project.(don't be forgot to wait until successfully finished Build.)
6.) Run the project, your browser should launch and the button “Click me!” and the text “Hello, GWT!!!” should be visible.
Cheer ! now you can create GWT sample project on NetBean IDE.
You can also create GWT's
Test Case
Constants
Module
RPC Service
UiBinder
By right click on your_project > Other... > Google Web Toolkit.
Have some useful tips for you !

IDE for Java C/C++ Project Compilation

I have joined a project where the application being worked on involves Java, C, and C++ code with some JNI. Up until now, development was done in Linux from the terminal with a messy recursive makefile structure. Recently, I have been importing this code into an IDE (Eclipse) and was wondering something. Is it best to have one project in Eclipse containing the Java code and another separate project for the C/C++ code or everything in one Eclipse project? Why or why not? What would you recommend as the best way to achieve whichever option you suggest?
I have single project in Eclipse which mainly use C/C++ code and additional scripting languages - lua, python, bash-scripting and some pieces of java. Build system - makefile, but currently integrate scons build system and remove makefiles trash. So, Eclipse is good and you don't need to create separate projects, you can create all in one project.
I would recommend researching the option of mavenizing your projects. Possibly you can create a multimodule project with some modules as java projects and others as C/C++. Java projects in Maven work out of the box, with C/C++ you can have a look here: Using Maven for C/C++ projects. You can then use your IDE (Eclipse, Netbeans) to execute maven goals.
I haven't done it, its just an idea and seems doable.
Actually compilation of java is already separate from c/c++. You are just calling separately gcc and javac in makefile. So in eclipse if you point your workspace to your java source code, you can use Eclipse IDE as an great editor and for compilation. You can again compile your code in makefile or use generated class files of eclipse.

MySQL, Eclipse, and Java - is Ant required?

I am starting my first project with MySQL and Java in Eclipse. I found a tutorial:
http://download.oracle.com/javase/tutorial/jdbc/basics/gettingstarted.html
It is full of ant builds and XML files which make me want to explode. Do I really need to use ant builds or can I just import the MySQL driver into my project and import the libraries into the class and away I go? MySQL is already setup.
If you are a beginner and just want to learn some Java and MySQL, then Ant is not required. If you are building a project for some class or project. Then Ant is something that you should use. Ant automates your manual steps like compiling and packaging which will become a overhead over a period of time. Ant just manages your build process.
If you are not into build and stuff then happily skip ant. Just add the mysql connector Jar to your classpath and you are good to go.
You don't need Ant for development, Eclipse can build your projects just fine.
Once (if) you get into build automation, take a look at Ant again. Before that, you can safely ignore it (as long as you still know how to follow the steps in your tutorial).
Ant is not required for Development, with help of eclipse can build your projects.

Java equivalent to VS solution file

I'm a C# guy trying to learn Java. I understand the syntax and the basic architecture of the Java platform, and have no problem doing smaller projects myself, but I'd really like to be able to download some open source projects to learn from the work of others. However, I'm running into a stumbling block that I can't seem to find any information on.
When I download an open source .NET project, I can open the .sln file with visual studio and everything just loads. Sure, there's occasionally a missing reference or something, but there's really very little configuration required to get things going. I'm not sensing the same ease of use with Java. I'm using eclipse at the moment, and it feels like for every project I have to create a brand new Eclipse project using "create from existing source", and almost nothing compiles properly without significant reconfiguration. In the case of web projects, it's even worse, because Eclipse doesn't appear to support creating a web project from existing source. I have to create a standard Java project from source, then then apparently modify the project file to include the bindings for the web toolkit stuff to work properly.
Assuming I want to be able to contribute to a project later on, I shouldn't have to be making such drastic changes to the file structure to get my IDE to a workable state. What am I missing?
The best way to go about this, is to first remove the IDE from the equation. In C# there is only one environment, so the presence of the default IDE is assumed. In Java a default IDE does not exist.
In the end Java is all about java source files and supporting jars. If you figure out what those are, your 99% of the way home. Then you can apply you favorite build system for the set. Some project require a runtime environment, like a webserver to handle the JSP files. If you understand what the basic setup is (as specified by the specification) you can quickly setup your IDE to handle that.
If I get a project with java files and supporting jars, I fire up Eclipse, create a new project, point it to the project's base directory and Eclipse will automatically detect what it finds and set up the project accordingly.
But projects often come with a build environment included. The trick is to figure out which one:
if a build.xml file is present, it is using ANT. This is a "make" like tool. You can execute "ant" in the directory where the build file is (if you have ANT installed) and it will try to compile. All IDE's like Eclipse and NetBeans recognize the build.xml file and allow for starting ant from inside the IDE. There is no guarantee the supporting jars will be present.
if a pom.xml file is present, it is using Maven. Maven is also a make like tool, but enforces a much stricter build cycle. Plus (and this probably is its biggest advantage) it automatically downloads supporting jars. If you have Maven installed you will be amazed at what it downloads... just sit tight, it'll work out in the end. IDE's usually require a plugin to support pom.xml, but then you automatically have the whole project setup at once.
if a .project file is present, it usually is a Eclipse project
if a nbproject directory is present, it is a NetBeans project
Getting to know a build environment / IDE is more work that trying to setup a project in the one you know. So I always try to get it running in Eclipse. Usually projects are quite simple to get running once you know your IDE.
Having multiple ways of doing things is not always pleasant, but it's the cost of having an open community. If there is only one IDE it makes things easier, but I like the fact that there are more people trying to figure out what the best way is to get things done.
In some cases you really may have to make drastic changes. A well-designed build system will require no configuration at all on most platforms and perhaps a few changes on exotic platforms. However, there is no single standard build system for Java; some people use Eclipse, some people use Apache Ant, and others use Apache Maven or Apache Maven2. If you were to create a project from scratch, then Maven or Ant is probably the ideal way to go. If you use the NetBeans IDE, projects that you create will automatically contain an Ant build file (so that it can be built on all systems using Ant), but will add additional metadata so that it is recognized by NetBeans IDE. If you create a Maven project, either using Maven directly or using an IDE such as Eclipse or NetBeans, then that same project can be loaded in either NetBeans or Eclipse without any additional configuration changes (although you may need to install a plugin for Eclipse for it to recognize Maven projects; NetBeans recognizes Maven projects out of the box). If you are starting a project from scratch, you may be interested in the Java Project Template. If you are contributing to an existing project, how you view/edit the project depends on the build system chosen; if the project already uses Maven or Ant, loading it with other IDEs should be fairly simple, while if the project uses a specific IDE's quirks or uses some more exotic build system, it may be harder.

Categories