importing java source into netbeans - debugging

I need to quickly come up to speed on a java application written by another person in our organization. There are 309 java source files and I'd like to bring the source into NetBeans 8, create the java classes, and step thru the source using the NetBeans debugger. How do I go about doing this?

I'd try to find out what was original IDE the project was created. It might be possible by viewing files that are in the project root folder. NetBeans may know how to import e.g. Eclipse or maven project.

Related

Netbeans maven project reverting to Java project on restart of netbeans

I am using Netbeans 8.2 (although this problem has been ongoing in previous versions). I can create a maven project, cut and past a previous one into that project, and then build the project and run it no problem.
When I shut down netbeans though, the maven project changes to a java project and the only fix I can find is to create a new maven project and repeat the cut and save.
There must be a better solution to this, if anyone has had a similar issue and fixed it please let me know!
Any help much appreciated,
Kris.
you are probably copying some files that make the folder recognisable as a Java project. So likely have some build.xml in the base folder and/or some xml files in nbproject/ subfolder that are java project specific. Just copy only the source files you have.

How to create a Java EE 7 Maven IntelliJ Project

I am new to Stack Overflow because of my frustration to build a working Java EE 7 Project with Maven and IntelliJ ultimate.
I learned a lot about JPA and JSF in the last weeks and am thrilled to put my knowledge to use but unfortunately I am not able to create a working project structure as I get all sorts of errors along the way. I haven't found a single up to date tutorial which is working on the entire Internet.
My greatest achievement is creating a Maven project, and run the index page on a Jboss Wildfly (11) server.
I know Maven (3) requires a certain structure to work, I read that it is the one in picture 1.
Picture 1
Furthermore I know that I can add framework support by right clicking the project name and that I can add facets or modules by selecting files and project structure.
I would be very thankful if someone could explain the right creation of such a project. I already wasted double digit hours and lost a lot of fun.
I had to create a Maven Project with IntelliJ. After that I added JavaEE Application under Framework Support and checked the boxes for JSF and Web Application under Java EE aswell.
Now this doesn't work alone, I had to put this in the right structure Maven requires. I moved the META-INF Folder to main/src/resources. After renaming the web Folder to webapp, I moved it to src/main.
To check, go to Project Structure/ Facets and check if the paths are set correctly.
After adding a local Wildfly 11 Server Artifact (war), IntelliJ starts the default browser and I get to the index page.
The Project Structure
I recommend you take a look at JetBrains page, they have a lot of tutorials on how to use their products. Here how to create new Maven project:
https://www.jetbrains.com/help/idea/maven.html#maven_create_project
Also, here you have information how an example pom.xml file looks like and how to build it:
https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
When you develop your project you can add dependencies to the pom.xml file

Maven in Eclipse?

I am a total beginner at maven, I have read about it online but I am still confused how it can be used. I have eclipse Oxygen version installed and when I open projects I can see maven project option is already there. I was even able to create a maven project using YouTube tutorial. But now then I saw popular plugin called m2eclipse but I am not able to comprehend why is it actually used; when my application ran without it.
I am learning maven to get started with spring boot but I am finding it really overwhelming where to begin with, and many of the tutorial sites state to download maven (But maven already comes along with eclipse?)
Please explain.
Apache Maven is a build tool - a tool for compiling the source code of a project into a program that you can run (for example a jar file, or a war file that can be deployed on a Java EE application server). Besides automating all the tasks for building a project, it also gives you a standard way to organize your project and to keep track of dependencies (libraries that your project needs).
Why do you need such a tool?
When you write a small program that consists of one, or maybe a few source files, it's easy enough to compile it by hand on the command line, by directly using the Java compiler javac that comes with the JDK.
But when your project becomes more complex, and you have hundreds or even thousands of source files in multiple modules, it becomes really hard to keep track of everything and cumbersome to compile the files using javac. If your program needs libraries, it becomes even more complex, because you have to make sure that all the libraries are on the classpath, and some libraries need other libraries, which also have to be on the classpath.
A tool such as Maven helps you to compile all the source files in the right order and to keep track of all the libraries. Maven can automatically download libraries from the web and add them to your project, and downloading everything and building the whole project can be done with one simple command such as mvn clean package.
Spring Boot is part of the Spring Framework, which is a huge framework with tons of useful functionality for developing projects in Java. A Spring Boot project typically needs dozens of libraries, and it would be very hard to use if you'd have to keep track of all those libraries by hand - so that's why it uses Maven to manage all of this for you.
A Maven project is configured using a file named pom.xml - in that file, you describe your project and you put a list of libraries that your project needs. When you build your project, Maven will read the pom.xml file and figure out automatically what source files need to be compiled, and what libraries need to be downloaded.
m2eclipse comes preinstalled in Eclipse (at least when selecting "Eclipse for Java developers" or "Eclipse for Java EE developer"), thats why you were able to use Maven by default.
Still you probably want a command line Maven, because that's most likely how it will eventually run on the CI server, sometimes Eclipse Maven installation can produce different result than the command line install.

Spring STS not recognizing project structure with Gradle

I'm trying to do this getting started guide from Spring. So I cloned the project using git from the command line. As I'm working with Gradle, I removed the Maven files from the repository to clean the project.
After that I open my STS and go to File -> Open Projects from File System and navigate to the /initial folder of the repository. The project is imported correctly but when I try to add some "java stuff" (packages, classes, etc.) I get several errors and I can only add folders and files, which is quite annoying for working.
To be more descriptive, I'll add some images so you can see what's happening. This is the project initially imported into STS as I described above:
Then I try to add some java stuff, let's say for example a source folder. So Right Click on library -> New -> Source folder and this is the result:
And in the properties of library I have the following:
So the question is: how can I tell to STS to recognize the library folder as a Java Project (or Gradle module, I don't know how to call it) instead of a plain folder so I can add my packages and classes?
Thanks in advance for your answers.
In case you would like to work with Gradle, you should use the Gradle integration for Eclipse (project Buildship) and install that into your STS environment. After that, you should be able to import the projects either from disc as existing Gradle project (not as file system) or via the wizard that integrates the spring guides into STS (Import Getting Started Content). The wizard for the guides also let you choose between the Maven and the Gradle variant, so you don't need to close and delete stuff yourself.
Hope this helps!!!

Netbeans Project Configuration When Using Maven Project

does anyone know how to configure a project using maven? My issue is that when I create a project by doing New->Maven->Enterprise Application Project, I don't get all the IDE helpers that are available when I create the equivalent project using the default (which is an Ant project) option by doing New->Java EE->Enterprise Application Project.
If I go to the generated Main.java in the default project I get the option to use ALT+Insert which brings up useful Java EE code insertion helpers such as "Call Enterprise Bean", "Use Database", etc. These are not available in the maven generated project.
Looking at the default project's files, the project.xml contains this entry "org.netbeans.modules.j2ee.clientproject", which I believe is the IDEs instruction to generate the Java EE helpers for this project.
The maven projects project files, pox.xml and nb-configuration.xml, haven't got this entry. The nb-configuration.xml file does however have these entries:
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>1.7</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_j2eeVersion>
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>gfv3ee6</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
which must have something to do with the project setup. They don't give Java EE helpers though. Anyone have any idea how to add something like the defaults projects "org.netbeans.modules.j2ee.clientproject" to the maven project to get the helpers working??
Any help appreciated.

Resources