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.
Related
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.
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.
I have a simple Java project in NetBeans7.2, and when I try to Clean/Build it fails:
Building jar: D:\MEUS PROJETOS\_Workspace\JavaWorkspace\Mina\dist\Mina.jar
To run this application from the command line without Ant, try:
java -jar "D:\MEUS PROJETOS\_Workspace\JavaWorkspace\Mina\dist\Mina.jar"
Realizando o ofuscamento do código
Obfuscating dist/Mina.jar...
Created dir: D:\MEUS PROJETOS\_Workspace\JavaWorkspace\Mina\build\obfuscated
ProGuard, version 4.8
Reading program jar [D:\MEUS PROJETOS\_Workspace\JavaWorkspace\Mina\dist\Mina.jar]
Reading library jar [C:\Program Files\Java\jdk1.7.0\jre\lib\ext\jna.jar]
Reading library jar [C:\Program Files\Java\jdk1.7.0\jre\lib\ext\mysql-connector-java-5.1.21-bin.jar]
Reading library jar [C:\Program Files\Java\jre7\lib\rt.jar]
Reading library jar [C:\Library\Java\Home\lib\rt.jar]
D:\MEUS PROJETOS\_Workspace\JavaWorkspace\Mina\build.xml:28: Can't read [C:\Library\Java\Home\lib\rt.jar] (No such file or directory)
BUILD FAILED (total time: 5 seconds)
It's odd because I don't have that [C:\Library\Java\Home\lib\rt.jar] called in my project's library (there is no "C:\Library" in my computer at all)!
Also, why "rt.jar" is called again, if it's already called from "C:\Program Files\Java\jre7\lib\rt.jar"?
I have absolutely no idea where this came from, nor where I can change it (because it is not in my project's library list).
Thanks in advance! Forgive my bad english...
EDITED:
I just figured out that this issue doesn't happen when the application is compiled (build), but when NetBeans' ProGuard4.8 plugin try to Obfuscate!
I suppose that by "simple Java project" you mean the "Java application" project from "Java" category in NetBeans "New Project..." action from "File" menu.
Netbeans default build system is Ant. Ant is the program that compiles, packs and runs the source code from your project.
If you can't find the string "C:\Library\Java\Home\lib\rt.jar" anywhere in the project Properties window, the next place to look for are the properties files inside the nb-folder in project root (change from "Projects" to "Files" view) or the build{-impl}.xml files.
When you click on the "Clean and Build" action from the right click on the project icon in the "Projects" view ant reads the build.xml file (which imports the build-impl.xml file), finds the clean and jar targets, calculates all the dependent targets and properties needed to successfully run the aforementioned targets and finnally runs the calculated sequence of targets.
But, if it is a project made through the NetBeans "New project" action, the build.xml and nb-project are automatically generated, and changing the project properties from GUI effectivley changes the parts of build-impl.xml and some other files. In case you hadn't edited the automatically generated files, that is not the place to look for.
The next thing is to consider if it is Netbeans cache issue, see here for it's location, enter that directory and delete its contents (I can't guarantee it will help though).
Interesting thing is that rt.jar is usually in JRE_HOME/lib directory where JRE_HOME is full path to some JRE installation, so that might lead to conslusion that you have an JRE_HOME environment variable set to this (nonexistent) location.
It's all just guesses but something of this should help you. Please feedback.
I developed my program using Eclipse as my IDE. I used to use File|Export| Runnable JAR file option for creating dist build for client.
I was working with project using Run or (often) Debug button in eclipse (so I have configuration for project with valid main method).
Unfortunately when I created build yesterday I had following error when I tried to run app:
Failed to load Main-Class manifest attribute from My.jar
Then when I retried exporting I found the following problem in export log:
Could not find main method from given launch configuration
I have no idea what could cause this problem. I think I hadn't change anything in my project configuration. And I'm test my builds so I'm sure this option used to work correctly.
I will appreciate any help.
Are you selecting correct 'Launch Configuration' in the export dialog? Make sure it's from your project.
Also, once exported you could unzip jar file and look into 'META-INF/MANIFEST.MF' file - there should be 'Main-Class' entry with fully qualified name of your class where the main() method is.
I had this problem and none of the other options worked. Even removing and starting with a new workspace. In my case the problem was that I hadn't manually added the "classes" directory of my project to the classpath of the debug configuration that I was using to debug the java app. I don't know why it didn't pick up the classes directory automatically as part of the project from which I was running the app. In any case it started working again after that.
just had the same problem :s
it's annoying but easy to manually fix in the manifest file.
open the .jar file with winrar or 7zip.
locate the manifest file (META-INF folder)
change it to this.
Manifest-Version: 1.0
main-class: (package).(main-class)
In my case i had it in the default package.
Manifest-Version: 1.0
main-class: run
If you are not able to find your class file in Launch configuration, Right click on your project - > run as Java Application. Now export again.
I have an Eclipse project where I want to keep my Java project built into a JAR automatically. I know I have an option to export the project into a JAR; if I do a right click; but what I am really looking for is, that like Eclipse automatically builds a project's .class files and put them in target folder; it should also build a JAR automatically and copy the latest JAR at some or a specific location.
Is there a option to configure Eclipse in such a way, to build JARs automatically?
Just to make it clear for guys, patient enough to answer my question; I am not looking at ANT as solution; as I already use it, but what I would like it something that gets initiated automatically either with a time based trigger or immediate build with change.
You want a .jardesc file. They do not kick off automatically, but it's within 2 clicks.
Right click on your project
Choose Export > Java > JAR file
Choose included files and name output JAR, then click Next
Check "Save the description of this JAR in the workspace" and choose a name for the new .jardesc file
Now, all you have to do is right click on your .jardesc file and choose Create JAR and it will export it in the same spot.
Create an Ant file and tell Eclipse to build it. There are only two steps and each is easy with the step-by-step instructions below.
Step 1
Create a build.xml file and add to package explorer:
<?xml version="1.0" ?>
<!-- Configuration of the Ant build system to generate a Jar file -->
<project name="TestMain" default="CreateJar">
<target name="CreateJar" description="Create Jar file">
<jar jarfile="Test.jar" basedir="." includes="*.class" />
</target>
</project>
Eclipse should looks something like the screenshot below. Note the Ant icon on build.xml.
Step 2
Right-click on the root node in the project.
- Select Properties
- Select Builders
- Select New
- Select Ant Build
- In the Main tab, complete the path to the build.xml file in the bin folder.
Check the Output
The Eclipse output window (named Console) should show the following after a build:
Buildfile: /home/<user>/src/Test/build.xml
CreateJar:
[jar] Building jar: /home/<user>/src/Test/Test.jar
BUILD SUCCESSFUL
Total time: 152 milliseconds
EDIT: Some helpful comments by #yeoman and #betlista
#yeoman I think the correct include would be /.class, not *.class, as most
people use packages and thus recursive search for class files makes
more sense than flat inclusion
#betlista I would recomment to not to have build.xml in src folder
Check out Apache Ant
It's possible to use Ant for automatic builds with eclipse, here's how
This is possible by defining a custom Builder in eclipse (see the link in Peter's answer). However, unless your project is very small, it may slow down your workspace unacceptably. Autobuild for class files happens incrementally, i.e. only those classes affected by a change are recompiled, but the JAR file will have to be rebuilt and copied completely, every time you save a change.
Regarding to Peter's answer and Micheal's addition to it you may find How Do I Automatically Generate A .jar File In An Eclipse Java Project useful. Because even you have "*.jardesc" file on your project you have to run it manually. It may cools down your "eclipse click hassle" a bit.
Using Thomas Bratt's answer above, just make sure your build.xml is configured properly :
<?xml version="1.0" ?>
<!-- Configuration of the Ant build system to generate a Jar file -->
<project name="TestMain" default="CreateJar">
<target name="CreateJar" description="Create Jar file">
<jar jarfile="Test.jar" basedir="bin/" includes="**/*.class" />
</target>
</project>
(Notice the double asterisk - it will tell build to look for .class files in all sub-directories.)
Creating a builder launcher is an issue since 2 projects cannot have the same external tool build name. Each name has to be unique. I am currently facing this issue to automate my build and copy the JAR to an external location.
I am using IBM's Zip Builder, but that is just a help but not doing the real.
People can try using IBM ZIP Creation plugin.
http://www.ibm.com/developerworks/websphere/library/techarticles/0112_deboer/deboer2.html#download