Package Does Not Exist - Eclipse - java

I am new to Java so please forgive me if this has a simple solution (and I hope so though). I have added previously coded .java class files to my existing project in eclipse, while trying to import com.abc. and ctrl+space it even shows these packages and classes.
However when I try to compile it says "package xxx does not exist". I've spent hours researching on this but most of the solutions focus on .JAR files and I don't have a jar file. I even tried creating a .JAR file and then importing but I think I couldn't manage to success that.
I really need help about this and thanks for your help.
Regards

First of all you need to understand how to add jar files in eclipse project. You can place you're jar files in webinf lib folder.
And after that you can configure the project build path. By
Right click on project (in eclipse project explorer) > buildpath > you find configure build path.

Related

Converting Jar File into Eclipse Project

So I have an Eclipse project I have been working on for quite sometime now and my program that backs up the project hasnt been doing it for months, and I never bothered to check the back ups (stupid me). Well the project got corrupt and I lost all the files and dont have a back up that is even close to up to date. However I do have the jar file that is fairly recent (it only contains .class files) and I was curious if anyone knew how to convert a jar file with .class files into an eclipse project. Thanks for the help!
You can follow the steps given below:
Make sure you have a working decompiler in eclipse. If not, please install https://marketplace.eclipse.org/content/enhanced-class-decompiler into your eclipse.
Create a new Java project in eclipse > Right-click the src folder > Click import > Select Archive from the list to import your JAR
Expand the JAR in eclipse and double click a class file to decompile it.

Error jsoup in Eclipse

I am still receiving errors due to jsoup in eclipse. I have dropped the JAR in the project's tab, rightclick the JAR file and then chose Build Path > Add to Build Path but it still does not work.
http://imgur.com/SCqLxWN
Could you please help me?
#Thank you for responses!
I have done as you advised me but it still does not work.
http://imgur.com/Y5B9Em2
I am just a beginner but when I am using other packages everything works, I have troubles only with this jsoup. Do you have any other ideas?
Create a folder named libs in the root of your project and put your jar files here. Then go to project Properties, under Java Build Path > Libraries click on Add JARs... and select you jar file, under the libs folder.
Try to remove the following code as your class is inside the default package.
package org.jsoup.examples;

How to open a Project in NetBeans

Hi guys I just clean and build my project in Netbeans, copy the folder of my project, put it in a ZIP archive and send it to myself. Now I don't know how to deploy the project, I tried just to copy the classes and run it, but it give me so many error, even if I try to recreate the structure of the packages with the same name it doesn't work. I tried to find information on the internet but is not very clear.
When I click on Clean and Build.
NeatBeans create a folder with the name of the project and inside> build,dist,nbproject,src,web,build
When you clean and build under Netbeans, you should find all you need under the dist folder:
if you a creating a web application you should find a .war file - that is the file to deploy: just copy it to the webapps folder for Tomcat
if you are creating a standalone application or a library, you should find the .jar
Above assume you do not use maven for the project. If you did you would not have a dist folder, but the standard maven target one.
I don't really know what are the errors you get. However check these few things out and see if it works for you:
check if you are importing from an external Library, if so, make sure that you have those libraries within your project.
If you are creating a new project and just copy pasting the classes, then make sure packages are correct and not from the other project you had.
it is pretty simple to open a project in net beans:
after creating your project and building it, zip the whole project folder.
once you unzipped it, use "CTRL+Shift+O" or the third option in netbeans>file to open a project.
a filechooser should open and you can select the project you want to open.
this is pretty much the whole thing you need to do.
you can also find the .war in webapps folder, .jar in dist folder too.
your question is really unclear. We dont know what is your project exactly nor your errors.
Please let me know the exact errors. so that I can help you with better.
I don't understand exactly what is the error your facing but I think that if you use the export and import project features of NetBeans maybe you wouldn't have that error in the first place:
To export project:
go to File -> Export Project -> To ZIP... -> Specify the zip destination directory.
To import project:
go to File -> Import Project -> From ZIP... -> And browse your file system to find the zip you previously created.

how to fix the error "package weka does not exist" in netbeans?

I want to use weka with java.
I downloaded and installed weka and also downloaded the api weka-oneclass.jar. I am using netbeans IDE and so added this external jar file. But now when I start importing this package of weka, it says weka package does not exist. The package is listed in the classpath too. Can anyone help me fix this problem?
Can you see it in the Libraries section down the left hand side of the main screen in Netbeans?
If you right click on your project, and go to the libraries section, is your jar file listed in the compile tab?
Finally, if you open up the jar file in the libraries section, does it have the classes your after?
If thats all correct, I would try clean and build your project again.

Eclipse giving errors whenever I try to export to executable jar

I'm trying to export a small program that I have made in Eclipse Indigo today to an executable, however, every time I do so one of two problems occur. The program uses one resource which I was hoping to put inside of the JAR but Eclipse will not put in the executable jar no matter which option I tick when I export or which folder the resource is in - the first problem!
The second problem is that whenever I tell eclipse to "Extract required libraries into generated JAR" I receive the following error when I double click on the executable Jar:
Could not find the main class: main.Launcher. Program will exit.
I don't suppose that the second problem is too much of an issue at the minute but the first one is extremely frustrating so I would appreciate any help or advice. Thanks in advance.
(Strangely, and even more frustrating, if I go through the same process with a project I made a while ago with a previous version of Eclipse it works perfectly.)
The folder structure of the project is as follows:
In the project folder there are the following directories .settings, bin, src as default. I have put the resource, which is a png in the bin folder but I have also tried it in the src folder.
Can you give some details?
What is the structure of your eclipse project?
Of what type is the resource?
More important where in the project structure resides the resource file?
Is the folder of that resource file included as a source folder ? (seems to be a prerequiste to get exported to the jar)
Is it copied over to the bin folder when the project is built?
Many Thanks
Michael
Update:
I have built a very simple java project 1 Java class with a main method and put a sample png file in the source folder. I refreshed the project to have the png visible in the project, then I cleaned the project to have it build again, then I ran the Main class inside eclipse. This will give you a run configuration when exporting throught the wizard. Thereafter I exported the complete project as "runnable jar", selected the run configuration and selected "Copy required libraries in a sub-folder next to the generated JAR". The png was included and the Main class was found. The executable JAR could be executed.
(Environment: Eclipse Indigo R1, Ubuntu, JDK 6)
You might want to play through the complete sequence of steps I went through. Maybe eclipse just did not pick up a file or other updates.
regards, Mike
First of all, I would like to thank Mike (marksml) for being so helpful and attempting to provide a solution for my problem. Unfortunately, his answer did not work for me!
I began to look at all of my previous projects and noticed that the one I was having trouble with was the odd one out (because it was the only one that didn't work) and the factor that made it the odd one out, I found to be the JRE system library version. The project was using the JavaSE-1.7 library but when I changed it to the JavaSE-1.6 like my other projects were using it miraculously worked and exported flawlessly! I'm still curious as to why this is the case, but at least I have it working now...
With thanks and kind regards, Andy

Categories

Resources