Variable references non-existent resource Build.xml - java

I am using Eclipse Kepler and I am trying to execute my build script.
When I run a task, I get an Ant error that says
Variable references non-existent resource :
${workspace_loc:/MyProject_JAVA/dev-new/build.xml}.
The problem is this path is wrong. It should be :
/MyProject_JAVA/dev/dev-new/build.xml.
I can go into External Tools and change the config for this one build, but if I try to run the task again, I get the same error.
How do I change where Ant thinks the build file is?

I met same problem , fortunately I solved it.
Go into preferences of Eclipse, and edit Ant - Runtime - Classpath.
You will find reason, and delete the error configured entry.

I think your closing curly brace is misplaced and I'm not sure the colon is necessary. Try:
${workspace_loc}/MyProject_JAVA/dev-new/build.xml
EDIT: I'm assuming you are using this in your Ant Build external configuration's "Main" tab, in the "Base Directory" field.
EDIT 2: Actually, as I look at your description closer, it appears the MyProject_JAVA folder exists outside of the workspace. Is that correct? If so, try using ${project_loc} instead.

To add on to billni's answer, you may have an incorrectly defined Ant classpath.
Find the bad path within Window > Preferences > Ant > Runtime > Entries
I have 3 entry types:
Ant Home Entries
Global Entries
Contributed Entries
For my situation, the bad path was in > Global Entries
To fix this, remove the bad path by selecting > Remove
Add the new and correct path by either using > Add JARs... or > Add External JARs...
Add JARs... > allows you to add archives from your package explorer to your build path.
Add External JARs... > allows you to add archives from your local file system to your build path.
Assuming your path is correct, and that there are no other errors, your build should now work!

Had a similar problem, after I renamed the project using "Refactor"-->"Rename..." on a project for which I use an Ant builder.
I had to
open the project's Properties
go to "Builders"
select the Ant builder
click "Edit..." on the right hand-side
in the Edit Configuration dialog, in the "Main" tab, the "Buildfile:" field was pointing to a path containing the old project name. I changed it to the new project name and it worked.

Related

"The project cannot be built until build path errors are resolved"

Trying to import the source of jforum into eclipse, works so so, but I get aforementioned error "project cannot blabla..".
I found several threads about this specific error message, but none of them helped me so far.
Here is a screenshot of the error message and I believe it's easily fixed since it's simply a matter of a configuration (or lack thereof):
http://i.imgur.com/sVtYorM.png
I just did a clean install of Eclipse, and I'm thinking I might have forgotten to setup the Tomcat server? Or are there actual java libraries that needs to be copied over somewhere?
thx in advance ;)
You classpath seems to expect a variable TOMCAT_HOME
If this variable is expected then you can define that in
Preferences > Java>Build Path > Classpath Variables.
Add a new variable with name TOMCAT_HOME and the path should be your tomcat home directory. All these jars that are missing should be present in the tomcat lib folder.
From Screenshot I realize You are going with class path variable which is no longer valid
Goto Eclipe -> Window -> Preferences -> Java -> Build Path -> Classpath Variables
check the aboved jar files are present or not. Add/Edit if required so.

Accessing Existing Java Files in Eclipse

I want to access a folder that contains already written java files and img files in Eclipse. I did it already with one folder but I don't remember how. I want to get everything in one place like in this picture
Error
File > New > Java Project
Type a name into the "Project Name" box
Uncheck "Use Default Location" and put in a path to your folder
4. Click Finish
You may also need to set your source folder to be a source folder. Right Click > Build Path > Use as Source Folder
If you end up with access restriction errors on system libraries, follow the instructions given here -- delete the JRE library from your build path and add it back.
I ended up creating a new project and creating a new folder, and then linked it to the existing folder i wanted to add

Failed Ant build - The libs.CopyLibs.classpath property is not set up

I am trying to create a .war file from a svn source code that appears to be built using NetBeans.
I am aware of the question The libs.CopyLibs.classpath property is not set up
However, I would like to provide further details about my setup and the answers in the other question don't resolve my issue.
I am using Eclipse Luna & Ant version apache-ant-1.9.4. Could someone please enlightenment me whether I actually need the file and if so why? I downloaded the missing jar and the title of the jar is "org-netbeans-modules-java-j2seproject-copylibstask.jar" which suggests to me that this jar is IDE-specific. Just making an assumption here.
Here's my error message that I receive in a command prompt on running "ant" command.
BUILD FAILED
C:\eclipse_workspace\MyProject\xyz\project\build-impl.xml:476:
The libs.CopyLibs.classpath property is not This property must point to org-netbeans-modules-java-j2seproject-copylibstask.jar file which is part
of NetBeans IDE installation and is usually located at /java/ant/extra folder.
Either open the project in the IDE and make sure CopyLibs library
exists or setup the property manually. For example like this:
ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar
I can see that message is coming from my "build-impl.xml" file. But I don't really understand the purpose of the file and how to resolve this issue since I don't even have Netbeans installed on my machine.
<target name="-init-taskdefs">
<fail unless="libs.CopyLibs.classpath">
The libs.CopyLibs.classpath property is not set up.
This property must point to org-netbeans-modules-java-j2seproject-copylibstask.jar
file which is part of NetBeans IDE installation and is usually located at
<netbeans_installation>/java<version>/ant/extra folder.
Either open the project in the IDE and make sure CopyLibs library exists or setup the
property manually. For example like this:
ant -Dlibs.CopyLibs.classpath=a/path/to/org-netbeans-modules-java-j2seproject-copylibstask.jar
</fail>
<taskdef classpath="${libs.CopyLibs.classpath}"
resource="org/netbeans/modules/java/j2seproject/copylibstask/antlib.xml"/>
</target>
I have managed to find a working solution for my situation.
1) Downloaded and added the org-netbeans-modules-java-j2seproject-copylibstask.jar to my Ant/lib directory: C:/apache-ant-1.9.4/lib/
2) (in command line) Navigated to the folder containing my "build.xml" file, so it would be "abcfolder"
C:\eclipse_workspace\myproject\abcfolder\build.xml
3) Ran the following commmand
ant -Dlibs.CopyLibs.classpath=C:/apache-ant-1.9.4/lib/org-netbeans-modules-java-j2seproject-copylibstask.jar
I got a successful build.
simply only a call of the netbeans frequently updates (Help --> Check for Updates) solved this problem on my PC (using NetBeans 8.0.2)
checked for updates in netbeans(Help --> Check for Updates) and the problem got solved. This solved my problem......
Earlier i was thinking to re-install netbeans, but being a lenghty process I decided to search for the solution and luckily found the solution.
Guys every prob has a solution, try to get the solution in your way.....
Using NetBeans, You can resolve this problem using these steps:
In NetBeans, select Tools > Options > Miscellaneous > Ant.
In the Properties section, add the following property:
libs.CopyLibs.classpath=/java/ant/extra/org-netbeans-modules-java-j2seproject-copylibstask.jar
/java/ant/extra/org-netbeans-modules-java-j2seproject-copylibstask.jar
must be your org-netbeans-modules-java-j2seproject-copylibstask.jar file path
I updated the build.xml file and it worked
<target name="-init-taskdefs">
<property name="libs.CopyLibs.classpath" value="(path of netbeans
folder)/java/ant/extra/org-netbeans-modules-java-j2seproject-copylibstask.jar"/>
<fail unless="libs.CopyLibs.classpath">
thank you, for referring this
If you get "
Could not load definitions from resource
org/netbeans/modules/java/j2seproject/copylibstask/antlib.xml. It
could not be found.
" this error after setting Tools > Options > Miscellaneous > Ant in the Properties , adding property-
libs.CopyLibs.classpath=/java/ant/extra/org-netbeans-modules-java-j2seproject-copylibstask.jar
Then add jar in the upper field "Classpath" add this "org-netbeans-modules-java-j2seproject-copylibstask.jar" jar located in your netbeans installation location inside "NetBeans 8.0.2\extide\ant\extra".
For the main answer the setting in Netbeans. You may find is in Tools > Options > Java > Ant
And it may be easier to click Add Directory next to the Classpath window and navigate to the ...\java\ant\extra to add that whole folder.

Eclipse - Source not found

I know this question has been asked many times before, but none of the proposed solutions resolve my issue (or I'm not implementing them correctly).
I'm developing a plugin for OpenFire, and when I set a breakpoint in my plugin source Eclipse reports "Source not found". The JAR is built separate from the build of the OpenFire server. I've tried adding the JAR and specifying the source code directory, but no dice.
Here's the process I'm following: When I hit my breakpoint I'm clicking "Edit Source Lookup Path", clicking "Add", Java Library, User Library, click User Libraries, adding my library (tried both "Add JARs" and "Add External JARs"), and then specifying the folder that contains the source code. I've also tried:
Adding the source by selecting "File System Directory" instead of "Java Library"
Adding it by selecting "Workspace Folder"
In the Project Explorer, adding the source for my plugin to the Java Build Path
In the Project Explorer, adding my JAR as a Library and specifying the Source attachment
Thanks in advance for any suggestions.
Personally, I have no good experience in Eclipse JDT, when adding a source folder at the time it hits a break point. What I always prefer to do, is adding the source folder before debugging:
Select Project/Properties/Libraries
Select your library and "edit..." the source attachment
Select either the corresponding source folder or the zip/jar containing the package
After that, you should be able to open the source files in the virtual "Referenced Libraries" folder (directly below the "JRE System Library" folder inside the project), or when opening a reference to a linked class file from within the JDT editor. If you are able to access the source, then you should also be able to at least stop at the break point and see the corresponding source.
Else, you will have to check again, if the source folder is really valid: The source folder or source archive must contain the folder with the name of the root package of the library (e.g. the default Java "src.zip" inside the JDK folder also includes a corresponding "java" folder at its root). When in doubt, extract the archive and select the parent folder of the package you are interested in - sometimes source archives might be a mess or incompatible to JDT.
If this has been assured and it still doesn't work, chances are, that your linked source folder does not correspond to the compiled version of the library. Usually JDT will handle such inconsistencies fine, but if you try to open a source file, that is entirely different than the corresponding class file, you will encounter problems. In this case I would suggest either downloading the correct source version of the library, or recompiling the library from the source, if all else fails.
If opening a referenced source file from withing the JDT editor does work fine, and you are still unable to open the source files when a break point is entered during debugging, then most likely the class files are missing the line numbers of the corresponding source file. Again, you will have to recompile the library from the source in this case.
Finally, it is also possible to overwrite the default source lookup by specifying source folders or archives in the source tab of the launch configuration. But you should normally not need to do this, when your build path is configured correctly. From the Eclipse Help:
The Source tab defines the location of source files used to display source when debugging a Java application. By default, these settings are derived from the associated project's build path. You may override these settings here.
I had this very annoying problem for a long time but was finally able to solve it. In my case, a null pointer exception was being thrown somewhere in Java's Transformer.IsRuntimeCode(ProtectionDomain) function.
I didn't really need to know about this since the exception was being caught and handled, but eclipse would pause debugging every time this happened and tell me that the source wasn't available. As a result, I constantly had to keep pressing the button to continue code execution.
In order to prevent this from happening, I:
1. Clicked on the "Breakpoints" window at the bottom of the debugging
screen
2. Right clicked "NullPointerException"
3. Unchecked "Caught"
This prevented the debugger from pausing program flow during a caught NullPointerException.alt text
(source: SharpDetail.com)
And this another one as:
Eclipse doesn't crash. You're trying to step into a method, where eclipse doesn't know where to find the source (*.java) files and informs you about this. Here is how to tell eclipse where to look. Go to
Window->Preferences->Java->Installed JREs,select the JRE you are using and click Edit.
There, select all of the jar files in the list you see and and click Source Attachment....
In the window that shows up, select the fille src.zip, which is in your JDK folder (if you didn't uncheck it while installing the JDK). On the machine I'm on right now, that is
C:\Program Files\Java\jdk1.7.0_07\src.zip.
Save all your changes (possibly restart eclipse) and you won't see that error again.
Well it turns out the solution was anticlimactic. When Balder's recommendations did not work I tried debugging one of the stock OpenFire plugins and it worked just fine. I then created a new plugin from scratch, and by doing nothing other than adding the source to the project (Right-click on the project -> New -> Source Folder) it also worked just fine. I have no idea why Eclipse refuses to see the source for my original plugin, but I moved all my code and libraries over to the new plugin and debugging is working as expected.
Many times you put jar files in eclipse IDE as referenced libraries when binary version of application was downloaded. Usually done so by configuring the build path. But the binary does not have the source files. You have Binary version and source version of application.
One simple way is to download the source libraries that you also use maven to build the project.
Keep somehwere, may be inside your project workspace.
Now while seeing the class file (from eclipse, jar exploded) you may see the source not found, fine.... there is a button below and click on that, a new window opens and there select add external folder.
Reference it to the src folder of the source you downloaded(not the binary one) and kept somewhere as said above and it will show the class details from that.
I fixed this issue with doing the following:
Click at the menu Window - Preferences - Debug - Step Filtering And check all the packages like the following image.
(Step Filtering)
Then, debug again your project and thats it.
Best regards,
In my case, I had a breakpoint in the class declaration. I mean in the next line.
public class GenerateInterface implements JavaCall {
So, the debugger stopped in that line and showed the following message:
Source not found
I think unconsciously activate the breakpoint in that line.

Java - Problem with the classpath on Eclipse

I'm trying to recompile a project I've been working on and I keep getting an error message when trying to load a property file:
The system cannot find the path specified.
I guess this has to do with the classpath. But I've added the path to the file in Properties-> Java build path-> Libraries (external class).
I also checked the .classpath file generated by eclipse, and the path is really there!
Why isn't Eclipse looking at the right path?
There 2 different classpaths, build classpath and runtime classpath. The one you are setting is the build classpath.
Check your runtime classpath by going to Run -> Run Configurations and select your application configuration. Check the classpath setting there.
There is another workaround for this also. Eclipse by default will include your output folder (usually named bin) in your classpath. Typically anything that are not compilable in src folder will be copied to bin as is. I assumed your property file is not located in src folder. What you can do is to open your project property and add the folder where your property is located into Java Buld Path -> Source (tab). This way eclipse will copy the content of that folder into bin and will be in the classpath.
There are several ways to read a property file:
Have it in the current working directory (the one cd'ed to). You can do this in the Eclipse launch configuration. (Run -> Run...)
Include it in your application, by having it in a source folder. You then need to read it in through a class loader to be able to get it always (when jarred up, through Java Web Start, etc).
Double check if the property file or its directory is in the excluded list of the project Source. If it is remove the exclusion filter and try recompiling.

Categories