I have an R package that interacts with a java dependency (jar file) via the rJava package. I have no issues making things work when developing, but I don't know how to get the package installer to keep the jars with the installation in some sort of java src directory (e.g., file.path(.libPaths()[1], "mypackage", "java"). Is this possible without needing to write custom configuration files?
I am attempting to install using devtools::install_git. My source data is organized like most other R packages (I'm using the other features of devtools as well) except that I have an additional subdirectory java where my java dependencies are stashed.
Thanks
Keep the jar files in /inst/java and have something like the following in zzz.R
.onLoad <- function(libname, pkgname) {
.jpackage(name = pkgname, jars = "*")
}
Related
I'm trying to find the best documentation and information on integrating custom Java files into a Clojure project. I've reviewed the project Enlight and see that the files are all .java files under the /src/main/java directory. Unfortunately it doesn't use Leiningen (what I'm using) so I can't see how it is called together the java files.
Suppose I want to use a big Java project from Clojure, like MALLET, which is abstracted into oblivion that a standard, major, main entry point like public static void main () cannot be found. Do I just dump every .java file into my classpath and hope for the best?
To include your own .java files in Leiningen project:
(defproject my-project "0.0.1-SNAPSHOT"
; ...
:java-source-paths ["src/main/java" "src_other/java"]) ; It's up to you how to structure paths
In this setup your .java files compilation will be managed by Leiningen.
To include existing Java project which is available in some of Maven repositories, just add dependency. For MALLET it will look like:
(defproject my-project "0.0.1-SNAPSHOT"
; ...
:dependencies [[cc.mallet/mallet "2.0.7"]])
Finally, if the goal is to include private jar file - the best option is to create local Maven repository.
In all of these cases you will be able to do normal Java <-> Clojure interop.
I am learning RObotoframework using - Java.
With user defined java file I am getting error "Test Library 'mavenPackage.MyKeyWords.java' does not exist".
If I don't use this file, test is running fine.
Only for importing my .Java file, I see this error. Please help!
I installed Jython.
In my "C:\robotfw" I placed...
1. robotframework-2.8.1.jar
2. robotframework-selenium2library-java-1.2.0.13-jar-with-dependencies
3. I placed the whole Java package folder (mavenPackage) here. Inside of this the .java file exists. (mavenPackage.MyKeywords.java)
I set the Classpath for the 1 and 2 JARS.
testcase.txt
* Settings *
Library Selenium2Library
Library mavenPackage.MyKeywords.java
You can't import directly the java file.
You must compile it and put it in your classpath according to the package of the class.
In your classpath you need RF jar, selenium jar and your classes.
You don't even need Jython as it is included in RF jar.
I would like to be able to have a separate directory where jar files that represent plugins can be added to a Play 2.0 project.
Jar files are normally kept under the /lib directory in Play. I'd like to separate my jars in a directory called /plugins
This question was asked before, but the suggestion was to just use the /lib directory.
Adding additional java files to playframework classpath
Is there no way to do this without manually changing the 'eclipsified' files generated by Play?
I suppose you can do that by altering the sbt build script. Should be as simple as
unmanagedBase <<= baseDirectory { base => base / "custom_lib" }
Here is the link to the sbt documentation.
I'm developping several java packages that are then distributed as jar files.
Due to some new requirements, I now have to program several new features in jython; these will probably cover quite a bit of code distributed over a lot of separate jython files.
I would like to continue with the distribution of a single jar file per package. I bit of search provided me with two approaches which are unfortunately both not very good:
1) jythonc: I'm using jython 2.5.1, so jythonc is no longer part of the distribution. Besides, I don't like the restriction this would place on my jython code.
2) Package everything together with the jython.jar file. Unfortunately, this is not possible; all of the people using my code package already have a jython.jar file in their environment (and many of them use different versions). In other words, my package must be distributed without the python core; instead I can rely on it being found in the classpath at the target system.
Now the question remains, is there another way of packaging all my java and jython code within one jar while keeping the jython.jar file untouched?
I finally found a solution for my problem. Maybe this is also of interest for someone else.
Just as a reminder, this is meant for a mixed java/jython package with java on top that will then be delivered to a customer, NOT for a self-contained application.
1) All jython sources are put in a separate folder on the top level within the jar file using the tool "jar" (or any other zip tool); I used the folder "Lib".
2) Access to the jython code from java is done using an object factory class modeled as a singleton (similar to the one described here); access to java from jython works straightforward with just the full package name.
3) In the constructor of the object factory I use
String jarPath = myObjectFactory.class.getProtectionDomain().getCodeSource().getLocation()
.getPath();
to determine the location of the jar file from within the code.
4) I add the "Lib" folder within the jar file to the jython module lookup path using
PySystemState newState = new PySystemState();
newState.path.insert(0,Py.newString(jarPath + java.io.File.separator + "Lib")); Py.setSystemState(newState);
As long as the jython.jar file is included in the classpath, this will work.
I have downloaded a complete package of Java product and trying to compile it using Ant. The project compiles with many errors, mostly related to imports starting with "org.apache.commons".
I'm new to Java. It looks to me that some system component is missing.
Some of the errors are:
package org.apache.commons.logging does not exist
package com.ibm.icu.text does not exist
cannot find symbol
What should I do to get rid of those errors?
As Sujee has said you need to include 2 jar files in your classpath. You can find the jars here:
http://download.icu-project.org/files/icu4j/4.4.1.1/icu4j-4_4_1_1.jar
http://apache.forthnet.gr/commons/logging/binaries/commons-logging-1.1.1-bin.zip
org.apache.commons.logging and com.ibm.icu.text are third party Java libraries. Download them from their websites and include in the Java classpath.
Update
Classpath is a list of file system paths which defines the locations of Java classes and libraries. JVM uses this to load the class it needs in the runtime. Usual practice is to put all libraries in a sub folder called 'lib' then add '\lib' in the classpath. My advice is to use a graphical tool like Eclipse so you don't need to manually do this. Please read this wikipedia article for more info about Classpath.