0

I've tried the following: .jnew("java/sql/Date", 1912324L)) (using the rJava package) and get the following:

Error in .jnew("java/sql/Date", 1912324L) : java.lang.NoSuchMethodError:

Same error when I try .jnew("java/util/Date", 1912324L).

Any ideas about why this is happening?

NB: This works fine .jnew("java/lang/String", "s")

Obligatory session_info():

Session info --------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.2.1 (2015-06-18)
 system   x86_64, darwin14.4.0        
 ui       RStudio (0.99.441)          
 language (EN)                        
 collate  en_AU.UTF-8                 
 tz       Australia/Sydney            

Packages ------------------------------------------------------------------------------------------
 package   * version date       source        
 crayon      1.3.0   2015-06-05 CRAN (R 3.2.1)
 curl        0.9     2015-06-19 CRAN (R 3.2.1)
 devtools  * 1.8.0   2015-05-09 CRAN (R 3.2.1)
 digest      0.6.8   2014-12-31 CRAN (R 3.2.1)
 git2r       0.10.1  2015-05-07 CRAN (R 3.2.1)
 memoise     0.2.1   2014-04-22 CRAN (R 3.2.1)
 Rcpp        0.11.6  2015-05-01 CRAN (R 3.2.1)
 rJava     * 0.9-6   2013-12-24 CRAN (R 3.2.1)
 rversions   1.0.1   2015-06-06 CRAN (R 3.2.1)
 testthat  * 0.10.0  2015-05-22 CRAN (R 3.2.1)
 xml2        0.1.1   2015-06-02 CRAN (R 3.2.1)

And...running Java 1.6:

java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)
1
  • 1
    The constructor of Date takes a long and you are passing an int. The other (deprecated) constructor works: .jnew("java/sql/Date", 115L,11L,10L). Commented Jun 23, 2015 at 11:26

1 Answer 1

5

The constructor of java.sql.Date takes a long as argument and you are passing an int instead. Since R doesn't have native float and long types, rJava provides the .jfloat and .jlong functions to convert numeric R vectors. This works:

.jnew("java/sql/Date", .jlong(1912324))

Keep in mind that you have to provide the number of milliseconds from the 1970-01-01, so it's highly unlikely that the value you provided is what you intend.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.