Java project issue in import - java

I am very new to java.
I downloaded Netbeans 8.2 and Jdk 1.8 and installed both.
And opened one of the projects where I'm getting three import statement issue.
import org.apache.commons.fileupload;
import org.apache.commons.fileupload.disk.diskfileitrmfactory;
import org.apache.commons.fileupload.servlet.servletfileupload;
I have my got the below jar in web-inf/lib path in project
Commons-fileupload-1.2.2.jar
Commons-up-2.4.jar
Please guide me to get the project compiled. I am clueless since I have no idea about java and trying to run the project and debug .

Import your jar files the proper way.
Right click your project >
Properties >
Libraries
Then click the Add Jar/Folder button to import the jars you need.
After this, clean and build the project (Right click > Clean and Build), and try to run it.

Your setup probably has some sort of error to find out the path to those .jar files, it is common to happen when you've got the files imported in a wrong way.
I'd like to suggest to you to use Maven. Maven is a dependency manager and will be in charge to manage all your dependencies along the build of your project among all other features. It is easy to use and will make your life a lot easier.
Here you have two links, one if you'd like to understand better how it works (https://maven.apache.org/guides/getting-started/) and the another to help you to build your Maven project (https://maven.apache.org/guides/getting-started/). I don't use NetBeans IDE but it probably has support for Maven, but in case it doesn't, you could look for a plugin.
Hope it helps.

Related

For IntelliJ, is there ANY reason to import Eclipse project vs. just importing the Gradle project?

I have seen many questions about importing Eclipse or Gradle projects into IntelliJ, but not a question asking which approach to use. I assume just import Gradle?
We use Eclipse over Gradle, I can build and run my projects either with gradle command lines or (less likely:) in Eclipse. As long as I can build with gradle on the command line my boss is happy.
I found the fully-enabled free student versions of IntelliJ/Jetbrains products, so I am using the Ultimate version 15.02. Gradle 2.8 FWIW.
Is there ANY reason to import the Eclipse project vs. just importing the Gradle project? And I guess in the last couple versions of IntelliJ you just open the Gradle file, not import a Gradle project?
Also still a good idea to leave auto-import turned off? And I notice putting apply plugin: 'idea'; in build.gradle is no longer necessary since version 14.
I'm not an expert in the differences from importing from Eclipse vs Gradle, but I would always import from Gradle when possible (this is true for Maven and Ant base builds as well).
Which datastructure do you want Intellij to use to figure out where your sources are? You can either use the same thing Eclipse used (the build.gradle file) or you can use the product of Eclipse's interpretation of the build.gradle file.
When you import from Eclipse, you're essentially saying "Instead of getting my information direct from the build tool's setup, I'm going to get my information that got its information from the build tool." You've added another layer for no real value in the import.
That said, maybe there are things that the Eclipse project settings that project import will include. I could imagine the Eclipse project import pulling in anything like manually included jars, but this means that your project probably requires an IDE to build it (which is terrible) and really you should refactor your project so that it can be built without any IDE assistance (from the command line).
So in short, import from Gradle directly. Don't go through Eclipse. You're just filtering the source data through a filter that isn't adding any value. Or if it is adding value, then it's probably a project specific configuration that shouldn't be done in an IDE anyways.
PS.
I always just go to the build.gradle file and "open" that. Same thing for pom.xml.
I always have auto-import on, both for Maven and Gradle based projects. I've never run into any issues with it and it keeps me coding faster.
I know, this is a fairly old question, but I just wondered the same thing.
Apparently, JetBrains recommends importing the build tool file instead of the Eclipse project when possible.
If your project uses a build tool such as Maven or Gradle, we recommend choosing the corresponding option when prompted in the Import Project wizard, and selecting the associated build file (pom.xml or build.gradle) IntelliJ IDEA 2017.2 Help

Unable to solve import classes in maven project

I am developing a maven project using IntelliJ-14. The other day everything was correct without any problem but today when I got in the project some of my imports are not working. When I compile it is everything ok and I can run the project but autocomplete does not work and some classes appear red.
I've tried to go File-> Settings-> Maven-> Importin-> Import Maven Projects Automatically check. Already imported the project again and nothing. In external libraries classes exist.
An example of my code is here.
What else can I do to solve this?
Please help
Right click on the project-->Maven--->UpadateProject.
This may help you.
Some possible solutions since we can't tell what is actually wrong:
Delete your .m2 folder and do a reload maven project
Go invalidate "caches and restart" (File - Invalidate caches /
Restart)
If you work with other people see if they have committed something that breaks the maven build. Some times the version of jars that you have in your local maven repo (.m2 folder in your %USER_HOME% folder) is different than the one that they other devs using
Do "Reimport all maven projects"
I experienced the same problem. Before it occured, I created a package structure from within IDEA, for example "de.ulli.myPackage". Of course I expected to get the directory structure "de/ulli/myPackage". I don't know why, but actually there was a single directory named "de.ulli.myPackage" (OS Windows 7 64 Bit). Maven was able to build the project, and I even could generate classes via IDEA. But autocomplete didn't work and the classes within the package appeared red in other sources. After reparing the directory structure, everything was fine.

Import Java project from GitHub to Eclipse

I'm trying to import a project on GitHub into eclipse because there are a few things I want to add to it. However whenever I add it I get a ton of errors and problems with it...
The GitHub project is https://github.com/dmulloy2/SwornGuns
I've tried adding it to eclipse and it didn't work. I then tried making a project in eclipse and then put the files in, that didn't work. I also read online that going to Configure -> Convert to Maven Project would work, and then importing the spigot.jar file that this source depends on. However that didn't work and just gives me a ton of import errors.
The errors I am getting:
That project is a maven project. A simple way is clone that project into your machine, and import it as a maven project, with File - Import - Maven - Existing Maven Project.
Eclipse will help you resolve the pom file and configure project and download necessary libs.
First, make sure you are using Luna, the most recent version.
In eclipse, File > Import > Git > Projects from Git > Existing Local Repository.
In the Import Projects from Git screen, click add, then goto the location of the cloned repository. Click open, finish, then next. Select Java > Java Project, and click next again.
At this point, there are three options.
Import existing projects
Use the New Project Wizard
Import as General Project
Pick "Use the New Project Wizard". Then, uncheck "Use Default location", and click browse. Select a folder (You probably want the location you cloned the repo to), click "Open", and give the Project a name. Click next, and make sure that the src/bin folders are setup correctly, and click finish.
Whew!
Of course, the Import from Git option was only added in Luna, so update eclipse if necessary.

Importing GWT project to IntelliJ fails

I have a GWT project, which builds under Eclipse, but I am trying to migrate it to IntelliJ.
I appear to have imported it correctly, downloaded all the required libraries using maven / pom.xml, but when I try to make the project, I get the following error:
java: package com.infoshare.clearcore.shared.model does not exist
If I browse the sources, it is there, but using any of the IDE "goto" options fail.
The picture below shows the project structure, which has two modules one with the failing (auto generated) source code, and the other with the "com.infoshare.clearcore.shared.model" code. Is there some way I can tell the compile to look in both modules, or do I have to restructure the code?
How did you import the project? The best way I found to import Maven projects is simply to open the root pom.xml using File > Open, then IntelliJ will detect the project and import it automatically.
Eveything should be configured properly. in particular, the target folder should be displayed in another color, because the IDE knows it contains generated files (which is not the case in your current screenshot).

Import a maven project into netbeans

I'm learning how to create some applications in Java, i found a maven project example in a tutorial and went to compile it in netbeans.
I tried to search in the Internet how to import a maven project into netbeans, and i can't found a solution.
By the way, in the tutorial i downloaded something like pom.xml, i wonder what is it and how it can be used?
Thanks!
You can import Eclipse Maven project in netbean, just follow the steps.
1) In Netbean , File->New Project->Select maven in left Pane -> Select Project with existing POM on right pane and finish.
2) Now you will be asked to open a eclipse project just open it and that's it..
I hope you will solve your problem with this......
Although not really a direct solution to your problem, a work around to get you up and running is to create a maven project in Netbeans via the wizard, with the same name as the example project you want to install. Then, create the same package structure in the project as the example, then copy the files into their correct packages. Although you are not importing the project, but it should get you up and running.

Categories