1

I need to compile a scala code which calls a java code from it.

What I did:

1]I have a scala main file check.scala

package com.code
     class check {
       var Rectvalue = Array.ofDim[Int](5)
       val str = Array.ofDim[String](1)
       def nativeacces(arg: String, loop: Integer) {
         val test = new testing()
         test.process(arg, Rectvalue,str)
         }
     }

2.For creating instance val test = new testing() ,i added two .class(sample.class,testJNI.class) file from java source code inside the folder(package) com/code.

3.When I compile the scala code using

scalac check.scala

It generates the class file for the scala file.

What I have to do:

1.Instead of .class(sample.class,testJNI.class) file added inside the package ,i need to add jar file.

2.I tried, created jar file for the .class file and compile the Scala, it shows the error:

 scala:6: error: not found: type testing
 val test = new testing()

3.I need to link the .jar file and compile the scala main file

Has QUIT--Anony-Mousse
  • 70,714
  • 12
  • 123
  • 184
Cibin William
  • 303
  • 3
  • 15

1 Answers1

1

You can reference classes/directories/JARs via classpath option:

scalac -classpath your.jar check.scala

Related question: Adding .jar's to classpath (Scala).

If you want a proper build use SBT, put your JAR in lib directory in the root of project and it will figure out what to do for you. Here is Hello World of SBT.

Community
  • 1
  • 1
yǝsʞǝla
  • 15,379
  • 1
  • 39
  • 63