I've been running the built-in Ant from the command line on a Macintosh (10.5.5) and have run into some trouble with the Mail task. Running the Mail task produces the following message:
[mail] Failed to initialise MIME mail: org.apache.tools.ant.taskdefs.email.MimeMailer
This is most likely due to a missing ant-javamail.jar file in the /usr/share/ant/lib directory. I see a "ant-javamail-1.7.0.pom" file in this directory but not the appropriate jar file. Anyone know why this jar file might be missing and what the best way to resolve the problem is?
Here's what I ended up doing to resolve the problem:
Downloaded the latest version of Ant from http://ant.apache.org/
The "built-in" Ant is installed in /usr/share/ant; I didn't want to overwrite that version so I extracted the new, full version into /usr/local/share/apache-ant-1.7.1/
As npellow points out, the the Mac doesn't include mail.jar or activation.jar -- these files can be downloaded and extracted from JavaMail API and JavaBeans Activation Framework respectively and copied to the new ant lib folder (same folder as all the ant-*.jar files)
The ant command (/usr/bin/ant) is a symbolic link to /usr/share/ant/bin/ant; I updated this link to point to the new version (ln -s /usr/local/share/apache-ant-1.7.1/bin/ant /usr/bin/ant)
If for some reason you need to make the old version of Ant the default again, just use
ln -s /usr/share/ant/bin/ant /usr/bin/ant
Steps 2-4 were done at the command prompt as root. That's it -- the Mac now has the latest, complete version of Ant and the Mail task works just fine.
Download the Java Mail libraries from: http://java.sun.com/products/javamail/ .
You will also need http://java.sun.com/products/javabeans/glasgow/jaf.html
A list of all external dependencies required by Ant's optional tasks are outlined here http://ant.apache.org/manual/index.html .
Another way to get dependencies for Ant very easily, is to run:
ant -f fetch all
from $ANT_HOME. You can also run -projecthelp for a full list of targets:
all load all the libraries
antlr load antlr libraries
bcel load bcel libraries
beanshell load beanshell support
bsf load bsf libraries
debugging internal ant debugging
get-m2 Download the Maven2 Ant tasks
jdepend load jdepend libraries
jruby load jruby
junit load junit libraries
jython load jython
logging load logging libraries
networking load networking libraries (commons-net; jsch)
regexp load regexp libraries
rhino load rhino
script load script languages
xerces load an updated version of Xerces
xml load full XML libraries (xalan, resolver)
I also got this working a slightly different way:
Created directory ~/.ant/lib.
Downloaded JavaMail API and copied the jars into that directory.
Downloaded JavaBeans Activation Framework and copied the jars into that directory.
Downloaded Apache Ant 1.7.0 (not the latest, matches the installed version) and copied the apache-ant-1.7.0/lib/ant-javamail.jar file into that directory.
This only solves the problem for a single user account, but that was fine for my purposes and saved me the hassle of having two separate ant installations on my machine.
Related
I am working with Ewon hardware project which supports javaetk run time environment.
Now some of the functionality like JsonReader, Logger, etc are not available in javaetk. So I download this jar file externally and include it in my project.
Looks fine at Eclipse level! But at run time it shows error on Ewon error blog that class not found! Any suggestions, that how can I use this??
We could extract external jar files of higher versions of java environment and put it in our project's bin folder. So works fine!
I have javac version 1.6.0_16 already installed on Windows XP and I'm using both Dr.Java and command prompt to compile and run Java programs.
I downloaded and extracted Checkstyle 5.5 and Findbugs 2.0.1. I'm trying to install Checkstyle and the instructions stated that I need to include checkstyle-5.5-all.jar in the classpath.
My question is, should I place the Checkstyle directory in the lib folder of the jdk1.6.0_16 directory and set the classpath as follows:
C:>set classpath=%C:\Program Files\Java\jdk1.6.0_16\lib\checkstyle-5.5\checkstyle-5.5-all.jar
Is this correct? Should I do the same for Findbugs? Thanks in advance
EDIT: When I added the above path using the environmental variables, and ran checkstyle hello.java, I got the error: 'checkstyle' is not recognized as an internal or external command, operable program or batch file
Maven will solve this problem for you
It sounds like you're just getting started in the world of Java. To that end, I'd suggest that you look into Maven for your build process. Also, you should be using at least JDK1.6.0_33 at the time of writing.
Essentially, Maven will manage the process of running Checkstyle, Findbugs (and you should also consider PMD) via standard plugins against your code. It will also manage the creation of the Javadocs, linked source code and generate a website for your project. Further, Maven promotes a good release process whereby you work against snapshots until ready to share your work to the wider world.
And if I don't use Maven?
Well, just create a /lib folder in your project and stuff your dependencies into it. Over time you will create more and more and these will get intertwined. After a while you will enter JAR Hell and turn to Maven to solve the problem.
We've all been there.
in an app I'm working on I have an issue with a Java library which is here - https://github.com/kennydude/Boid-Twitter-API
When I run ant android which builds an Android package it builds fine and Eclipse can read the Jar fine.
But on my device it says that dalvik cannot locate any of the classes and eventually throws a ClassDef Exception.
I have used Jars before, so I'm wondering if it's my ant file that's broken
I would open your app project in eclipse (the one that depends on the Java library that is not found at run-time) and add the jar file the Java library produced to its build path. Then execute
android -s update project -p .
in the same directory as your apps' Manifest.xml file in order do generate ant build files.
After this, you should be able to build your app using ant by doing
ant debug
or
ant release
I fixed it by ensuring Ant was compiling to 1.6 of Java which is my target in Eclipse for the application.
Perhaps you're not placing your jar in the libs directory as opposed to lib directory? Here's a similar issue Java (Android) - class not found exception
First of all to build an apk with ant for Android you have to use ant debug or ant release, i don't know what ant android does and why you are using it but this command is not part of the standard approach to ant for Android, that's for sure.
Ant is just a building tools, if a developer provide a building solution in ant, does not mean that his application is for Android.
Under Android everything that is not a native library is converted in a DEX object, which is something similar to bytecode for the Dalvik, there is no jar or other container in your app.
This question may be helpful for you Adding a library/JAR to an Eclipse Android project .
There are a lot of conceptual errors in this topic, you probably want to study the Android platform before using it.
I would like to use html5 validator from LiipFunctionalTestBundle in my Symfony2 project.
So, I followed instructions on bundle's github page, but I got this error during python build:
IOError: [Errno 2] No such file or directory: './syntax/relaxng/datatype/java/dist/html5-datatypes.jar'
indeed, there is a "dist" folder under that path, but it's empty (no files inside).
I also tried to download file from daisy-pipeline, but it's deleted after running python build again
I'm using Java 1.7.0_04 on Ubuntu x64
As noted above:
You need to install JDK, not only JRE. That is because you need java compiler.
I am having trouble exporting my java project from eclipse as a jar executable file. My java project uses an external library (its called jri). I have exported the jri.jar file and set the library path for its native library in eclipse, and it works great in development in eclipse. However, when I export it as an executable jar file I get the following error:
Cannot find JRI native library!
Please make sure that the JRI native library is in a directory listed in java.library.path.
I have placed a folder called lib in the same directory as my project's jar; this lib folder contains jri's native library. jri's native library is not in one file but in a folder. This is the same setup I have in eclipse.
The way I am exporting my project in eclipse is
Export...
Java > Runnable JAR file
Copy required libraries into a sub folder next to the generated Jar
Finish
And my folder is organized like this
folder project
project.jar
project_lib
jri.jar
jri native library folder
The MANIFEST.MF of my project.jar is:
Manifest-Version: 1.0
Class-Path: . project_lib/jri.jar
Main-Class: index
What I want to achieve is to give another person a folder including project.jar and anything else needed so she/he can run it without needing to install anything else.
Thanks so much
Add a script containing something like that:
#!/bin/bash
java -Djava.library.path=project_lib/native/ -jar project_lib/jri.jar
I export some java projects that way.
This is relatively hard to implement. The solutions I have seen involve extracting the native libraries in the JAR to an OS temp directory and then loading it. I would go for an integrated solution for that. One Jar and Java Class Loader support it, and on the second page you will find links to similar tools.
You can put the libraries inside your jar:
Export...
Java > Runnable JAR file
Package required libraries into generated Jar
Finish
I always export this way.
I don't know if it will work in your case, but worth a try.
Edit:
See these links:
Instalation, setup and setting environment properly
What to do when getting Cannot find JRI native library!
My guess is that this have something to do with LD_LIBRARY_PATH not correctly been set. Or the file wich it is searching for isn't in the path listed.
You know I had the similar problems
Could not extract native JNI library.
all above proposes can't help me. I couldn't stop and start gradle deamon by using follow command:
gradle --stop
I saw that gradle deamon still not stopped in my processes. That's why I kill it in my process and all will be fine :)