Java Eclipse - How do I change the classpath? - java

I copied an Eclipse project from my PC (eclipse is on drive D) to the laptop (eclipse is on drive c) but when I try to deploy the agents I have in my project I keep getting the following error:
The archive **D**:/eclipse/plugins/it.fbk.sra.ejade_0.9.0/lib/libjade4/commons-codec-1.3.jar which is referenced by the classpath does not exist.
I changed all the libraries' addresses to the correct ones (C:/eclipse/plugins/it.fbk.sra.ejade_0.9.0/lib/libjade4/__etc__) for all of them by right clicking the project > build path > configure build path... but that doesn't work. I also tried to refresh the project, restart eclipse but still nothing..
Any suggestions?
Thanks a lot!

First make sure that the .jar file is exist in the given path,if so then you can easily try making a new project and copy your material to it, and configure it to the .jar path.
If this doesn't work you may need to remove the temporary files from your project and eclipse on your laptop.
Also, please give more description about what happens on right clicking the project > build path > configure build path ?
Hope everything works well.

I had the same problem and just discovered the solution to this.
Go to project>properties>Java Build Path>Libraries>Add External JARS.
After specifying JAR file at a certain location, you will see it in previous window "JARs and class folders on the build path:" with "JAR_fileName - C:\YOURPATH".
Don't stop here instead click on the "+" button to the left to expand it, and IF it says "Source attachment: (NONE)", you double click it and add the path to the JAR file by selecting Workspace location.
This solved the problem for me.

Had the same problem and non of the above solutions worked.
This is how I fixed it.
go to your project folder
open .classpath file (enable view hidden files if its not showing)
edit the path
delete the project from workspace. Imp: Don't select (Delete project
content) checkbox when prompted. !!!
re-import the same project

I had the same issue...
I was refering jars from a mapped drive, when I moved them to my local drives, it started working fine. Also try giving a shorte path for the jars.

Related

To create an eclipse project from just the folders

I work in an organisation where i am provided with a folder having codes and other things for particular application.
I want to open this folder in eclipse and be able to navigate to all the classes that are used through resources(ctrl + click).
The problem is when I imported the folder the eclipse worked same as that of a notepad. Any changes no error would be shown.
I even added the required jar files for that project.
What should I do? I just need to navigate and check out the classes that are used and declared. Pls Help.
P.S. - I work on Ubuntu Machine.
If you have a java project, you may need to configure the source directory(s).
This can be done by right clicking on your folder -> Build Path -> Use as Source Folder.

jar file is not working in the dist (swing project by netbeans )

I set a lookAndFeel synthetica theme for the project.After that it is not working(jar file in the dist).
Again I removed it and tried.Then it worked. I did clean and build.
Tried several themes. They all workedd in the project. But did not run in the dist.
What should I do? Please help me..
I have experienced this before in my projects. Most of the time it happen because of using icons and images.
When /Icons/calculator.png image in your package, it is not wrong in netbeans like this getClass().getResource("/Icons/Calculator.png").
this is working on netbeans. but not in jar file. you need to rename Calculator.png.
use jar file in console (CMD in windows , shell in linux) with this command
java -jar adress-jar-file/jarfileName.jar
then see error in console.
Just Right click on yoru projet in netbeans and select Set Configuration then Customize in the window that appears provide your Main Class by clicking the browse button or writing it manually and Clean and Built again
Plz make sure some points.
1) You have set main class properly.
Right click on Project-> project properties-> Run-> set Main-Class
2) You have set theme path properly.
3) Your themes are not corrupted.
4) You have build your jar properly.
Right click on project-> clean and build(Note: Do nothing while it finish building jar)
5) Your lib folder not corrupted (if it is present).
It looks like there maybe something wrong with your setup. In your project properties, under libraries have you by chance added synthetica.jar as a required jar. but m not sure try it
but you can simply do,
you could create lib folder manually in your project folder and then paste that jar in that folder then through netbeans go to your project then right click on libraries and then browse to find your project folder open that then click on lib folder that you have created open it then click on jar that you have pasted and that jar file will be added to your project.
I could resolve my problem.I'm sorry that I was used trial version Synthetica.jar. after I bought it and done every thing from the beginning. I resolved it. Thank you for your contribution to resolve it.thank you

Eclipse does not show src file

I have three different projects in my eclipse and yesterday src file became unvisible in one of the projects. Two days ago it was ok and I have no idea how this happened. I can not see src file in project explorer or package explorer.
Project Explorer :
However, if I look with navigator I can see all files in the directories.
Navigator :
I use Eclipse Indigo SR2 and IBM Rational ClearCase for first two project. The other is my local test project.
Do anybody know how can I get back to src file into the project explorer?
Thanks.
Try to right-click on the project and click on refresh.
I had the same problem today, it is because i switch to wrong view model.I suggest you to switch the project explorer to Package Explorer.
Check your Java build path to make sure the src is present. Right click the project and select Build Path -> Configure Build Path. If the src directory is not present in the build path, it will not show up under the Java area as you have shown, but it will be present in the Navigator.
I had the same problem in Neon - src folder had disappeared. One sub-directory in the src folder would show up but no other sub-dir and not the parent src file itself. No matter what I did in the buildpath configuration only the one sub-dir would show up. It looked like some kind of corruption in the settings. None of the above solutions worked for me, including deleting the project and all files, and then re-checking it out.
What did work was switching to an old workspace, importing a project and then switching back to the workspace with the issue. Magically, the project with the problem was again responding to my changes in the buildpath configuration. I'm not sure if I had to do the interim step of importing fromt he old workspace or not - possibly just switching back and forth would have worked but not sure.
Try removing (deleting) the project without removing the files (there is a checkbox that allows you to keep the project files).
Then re-import the project. Not sure if this will solve your problem, but I was facing the same issue and delete->re-import resolved it for me.
I had this problem today, and the issue was that the "src" folder was not correct in the "Source" tab of "Configure Build Path" window. It was there but the path was wrong, so it had a red X. Deleting that entry and re-adding the "src" path (from the project) resulted in putting the "src" folder back into the packages hierarchy.
In my case, this happened because of sharing the workspace between user accounts, the paths to the workspace and the folder beneath were not the same. One user accessed the workspaces locally, the other as a mapped drive, etc.
Fixing this and then standardizing the path to be identical for all who access sit, resolved the underlying problem that caused this issue to surface.
Restart your eclipse work space.
Also change open perspective in eclipse.

eclipse doesn't compile the project

I had running project opened in eclipse. After an accidental restart of windows, now when I open the eclipse I see my project is marked with a little red cross. Now when I run the main method I get a java.lang.NoClassDefFoundError.
I have tried restarting eclipse, Project -> Clean but it doesn't solve the problem.
When I checked the project directory, inside 'target' folder there are no compiled .class files. I tried building the project but I can't get the compiled class files, which is the reason for the error.
How do I solve this?
I tried all the solutions here, but here's what worked for me.
First, remove the project from eclipse.
Then, in your project folder, delete the 2 files that eclipse creates. They're hidden, but they're called .project and .classpath.
Finally, add the project back into eclipse and eclipse will recreate those 2 files and a new configuration for your project.
My specific issue was that it a project that was missing a Java Builder because it thought it was a scala project. The only way for me to reset this was by removing the project, deleting the 2 files, and adding it back in.
Maybe Eclipse's workspace files have become corrupted. Restart Eclipse and choose a new workspace folder (or choose Switch workspace from the menu). Then import the project files into a new project.
Try deleting the run configuration and remaking.
If that doesn't work, open the class, ctrl+f11 to run. That will force Eclipse to update its classpaths & rebuild its main indexes.
To delete the configuration:
- Menu -> Run -> Run Configurations.
- Select your configuration
- Press delete or use the delete icon
If you are using maven, this will likely fix it: Right click your project -> Maven -> Update project.. (or alt + F5), select your project, make sure "Refresh workspace resources from local filesystem" is checked and click ok.
My eclipse project has similar issue though the error appeared slightly different. I imported a third party java project into Eclipse, with Project > Build Automatically checked, do a Project > Clean..., no classes were generated in the output bin folder. Tried different options, no luck.
I noticed a red exclamation mark at the top left corner of the project name.
Right click on project name, Properties > Java Build path, I saw "Build path entry is missing: cci/src". Manually created src folder, the red exclamation mark gone. Do a Project > clean..., project compilation successful
P.S. The eclipse project is not properly organized, there are no code under src folder. I suspected src folder went missing while checked in by original author since there are no code there.
Was having the same problem and finally found the glorious hint here.
In my project there is one *.scala File and Eclipse Neon is incompatible with the Scala IDE, thus there is no builder for scala and the whole project is not built.
After removing the Scala file and the Scala Package from the linked Libraries )Project Properties --> Build Path --> Libraries) and afterward re-adding the Java Builder (no idea why this one went missing, but here's a useful help on how to add the Java builder when missing), the project could be built and run again.
Try refreshing and then cleaning the project.
For me the problem is in missing jars,the jars were added first and the location of those jars where changed after.
So When I correctly added all the required jars again to the build path, it starts to build project correctly.

Problem with Java Buildpath in Eclipse

In eclipse I have an error related to my build path.
The error:
Project 'XX' is missing required library: 'middlegen-2.1.jar'
But the library is deleted before the build path configuration.
Is there perhaps a problem with cache or so?
Has anyone an idea why eclipse say that the library is required even though the library was deleted before the build path configuration.
With Best
I guess you've deleted the library from a directory, but you've not updated the project Build Path. Right click on the project name, select "Properties", go to "Java Build Path", choose the "Libraries" tab, and see that your library is not in the list. If it's still in that list, remove it with the "Remove" button.
This error is due to probably either missing required library or due to caching of eclipse
Solution 1
Open project explorer window.
Right click on the project and goto Buildpath -> ConfigureBuildPath
Under the libraries tab check whether all the used jar files are physically located in the directory/web application library.If something is showing "RED X" mark then fix them by either putting the jar in the place or remove it or add it newly using add JARs
Solution 2
1.Try cleaning the project's using Menu->Project->clean (select the projects and clean it)
Solution 3
If your build path is very clear i.e no Red "x" marks then the error could be of eclipse caching.Then do below step
1.Right click on the project choose "close project".
2.Once the project is closed again right click on the project select open project
This solution will clear the eclipse cache.
Hope any of the solution should resolve your problem.
I had this same problem, but the steps above didn't help. I did a search through files in the Eclipse workspace and found files named .markers and .markers.snap that contained the bad path names under the folders in .projects that were named for the projects that weren't building. I exited Eclipse, backed up those files, removed them from the Eclipse workspace, and restarted Eclipse. The problem went away.
Your project configuration includes a reference to middlegen-2.1.jar on the build path. That file is missing. You can either a) put the file there, b) change the configuration to point to the file in another location, or c) remove the reference, cross your fingers, and hope the project compiles and runs without the jar.
I don't know what "the library was deleted soon" means, so if that is important to your question, you might want to rephrase.

Categories

Resources