java compilation error in eclipse helios - java

I have executable jar file which is running perfectly when i am double clicking on it. but when i extracted the source code from jar file using jdk gui and trying to execute it in eclipse helios it is displaying the following errors
The project was not built since its build path is incomplete. Cannot find the class file for ControlPoint. Fix the build path then try building this project
The type ControlPoint cannot be resolved. It is indirectly referenced from required .class files
I tried refreshing the source folder, changing the output folder of eclipse, but nothing worked for me.
Can anyone please help.

I think you need to specify the right JRE in your buildpath. Also, you need to check if all the required libraries are added to the buildpath.

You won't be able to build and run until classpath is fixed. Check whether a library containing ControlPoint class is in class path, if not, then add it there.
You can find the library this way
http://www.findjar.com/index.x;jsessionid=EBF627F4D0BAEC200B8DF6DE50C3C47B?query=ControlPoint
If the ControlPoint class is in the sources that you extracted then make sure that this source folder is in the sources paths, if not add it there in project properties -> java build path -> source

Related

Eclipse Java Build Path Jar Library classes not found even if available in jar

Recently I wanted to add the nebula shelf to my eclipse plugin. Therefore I added the org.eclipse.nebula.widgets.pshelf.source_1.1.0.201701302244.jar the build path of my eclipse project.
Sadly eclipse can't find the class files inside of the jar, even after cleaning and rebuilding the whole project.
Picture:
Checking the same jar file with jd-gui results in:
Picture:
I exported the *.java files with jd-gui and copied them to my project. Using this method my project built successfully and worked as expected.
Can someone tell me how I can use the jar file without exporting all of the java files manually? Thanks for your help! :-)
Do not use source jars. You can tell eclipse while debugging to use the source jar.
Add the jar to build path: right click on jar -> build path -> add to build path
Don't try to add Eclipse plugins directly to the build path of another plugin as it won't work.
Instead add the plugin to your target platform or import it in to your workspace.
Then add the plugin to your plugin's Dependencies. In the MANIFEST.MF editor you do this on the 'Dependencies' tab in the 'Required Plug-ins' list.

Update External Jar in Android Project

All, I have an external JAR that I'm adding to my Android project. However, as my jar is consistently updating and changing. When I update my JAR, I get the dalvik VM magic number error.
I don't understand how I'm supposed to fix this?
Here's the steps I've followed.
Adding The Jar Initially
Copy JAR to libs folder in my project
Run project
My JAR is picked up, installed everyone is happy.
Updating the Jar
In Eclipse, go to the jar in libs and right click -> delete.
Copy my new jar (same name) into the libs folder.
Receive bad class file magic error.
My Troubleshooting So Far
In eclipse, Project -> Clean...
Select my project, clean it.
Run it. Same error... magic number
Project Properties -> Java Build Path -> Remove Android Private Libraries
Now the private libraries aren't being re-added. (Which equates to missing imports in my Java project) Why is this a nightmare? Any suggestions?
Turns out that my issue was caused by the multiple JDK's I had. Android was defaulting to use JDK 1.7 while my console jar was using JDK 1.8

Unable to export any of my projects into a .jar file

Everytime I try to export any of the projects from my workspace into a Java jar file, I end up with an error:
JAR creation failed. See details for additional information.
Class files on classpath not found or not accessible for: 'Server Manager/src/me/Zahach/ServerManager/main.java'
And this error is repeated for every class in my project.
I tried reinstalling Eclipse, that didn't work.
I then tried to recreate a project and drag and drop my packages into it, that didn't work either.
What is going on?
The error is caused because of a missing .class file(s) for corresponding .java file(s)
In Eclipse
Goto Project->Clean and Rebuild the Project and then try exporting,
If it doesn't work then make sure .class file exists in the bin folder for main.java file in
your case
Another solution is to ensure that the Classpath is Valid
Also make sure that the permissions in your workspace folders are ok. I ran into this problem after updating Eclipse and then downloading some Maven dependencies.
In the end, what fixed it was doing a sudo chmod 777 -R workspace/MyProject
I have faced similar problem while exporting my java files into a compressed jar file, so I checked the Java Build Path of my project and found that the External jars I was referring to from the project are not present in the designated folder locations. Once I have resolved that, I was able to export my java files into a jar.
You may have any java file that is totally empty. You have that file in project with somethingName.java but inside it is nothing. So no bytecode gets generated for it and it throws an error. You can find that file in error details and delete it and try building jar again. It works :) Thumbs up
I had empty Java file classes causing the error.

Getting NoClassDefFoundError when using common.lang.StringUtils in android java code?

I am getting this error:-NoClassDefFoundError wherever the code is using StringUtils class or methods .I have correctly added the jar files to the code and is not showing any kind of error in my code(Using Eclipse Indigo).
Is there any kind of point I am missing out. I have used this jar file in other projects but they worked properly.
Please help If any one is getting similar kind of problem?Thanks
Yes, this because of your .jar file didn't import properly. Follow below steps -
Place your .jar file in your project's libs folder .
Import it into your project. And, GoTo project -> properties -> Java build path -> order tab.
Check, whether your .jar file checked and placed in order of 1st. This is the main thing.
Hope these steps helps you. Have a look at below image -
Note that the build classpath is different from the runtime classpath. You must add the required JARs to both.
It's one of the things I don't like in Eclipse...
EDIT: To add JARs to the runtime classpath: in Eclipse, double click the plugin.xml file associated with your project. On the Runtime tab there is a Classpath category. From there, you can add JARs to the runtime classpath.
Here is a screenshot to illustrate this:
Are the jar files in a lib folder or a libs folder?
Newer SDKs require the jar files to be in a libs folder.
I do not know how you execute your code, but it clearly means that the jar is not properly added to your classpath, especially if your code compiles in Eclipse.
Add it to your classpath -or re-check it is well added- when executing and it should work.
Right click on project, Select Build Path -> Configure Build Path and Select Libraries tab. Then with add Jars, add the jar in question.(if you are using eclipse)

Can I refer to a Java source path using a variable in Eclipse

Background
I'm using an Eclipse 4.2 (Juno) release to build a plugin for a Java application. The source code and classes for my plugin all reside within the project workspace. The application jar and its source code are, for various reasons maintained outside of the eclipse workspace and the application jar is produced by another build mechanism.
This isn't a problem as I have referenced the application jar file in my project using drag and drop and the 'Link to files' option specifying it 'Create link locations relative to: MYDEV', where MYDEV is a Linked Resource Variable I have created for each Eclipse installation. This lets me use the same eclipse project on multiple machines where the path to the application jar varies, but is always the same relative to MYDEV.
However, I cannot find a way to associate the application source code with this jar unless I use an absolute path. I only want access to the application source for debugging purposes.
Question
In Eclipse, how do I attach java source to a referenced jar in a way that allows a project to be used on multiple installations where the referenced source code has been relocated?
If the source is outside the proyect, then there's no way to access it without an absolute path.
The best solution is using a symlink inside the eclipse project directory to the actual source folder; eclipse won't notice the source is outside the project directory and everything will work fine, without having to relocate the source.
This is the only way I was able to do what you are suggesting (do not know if there are better ways).
Package a JAR file that contains the source code of the JAR file. Place it inside your project in a folder (you do not need to add it to your class path)
In the eclipse project right click on the JAR file and go to "properties" and then to "Java Source Attachment" From there select "Workspace" button and pick the jar file with the source code we added from the above step.
So the source attachment path will always be relative to the project. That way if you share the project via SVN, GIT or whatever, the source will always be available and it'll work if the user is running eclipse on Windows or Linux.
I've had a similar problem to you where absolute paths were a problem for people using different OS and not even using mapped drives via Samba helped that much.
Hope this helps.
The way I have solved this problem is to use a use defined library in eclipse. Here the steps that you can use to solver this problem.
Create a simple project in eclipse in the directory that contains the jars and the source code files.
Define a java user library add the jars to the user library and for each jar in the library specify the location of the source. If the source files are in a project that is in the workspace then the path will be relative to the workspace folder.
Export the user library as an .xml file
When another use wants to setup an eclipse workspace with the same setting as yours they will do two things.
Import the project that contains the jars and the sources into their workspace.
Import the user library into their workpsace.

Categories