I received a Scala jar and need to write a java program to use a method. The imported Scala method definitely works because it has been in production for years.
here is the program:
import com.company.VerifyApp // The imported Scala jar
public class Validation {
public static void main(String[] args) {
VerifyApp app = new VerifyApp();
app.main(args);
}
}
Decompiled Scala code:
package com.company;
public final class VerifyApp {
public static void main(String[] var0) {
VerifyApp$.MODULE$.main(var0);
}
}
Here are observations:
- Error message: cannot find symbol constructor VerifyApp()
- location: class com.company.VerifyApp
- Just a note that this location is correct
- VerifyApp, from the decompiled code, is a final class with no constructor (thus should have a default 0-arg constructor)
- I'm using IntelliJ and activated the "Include dependencies with "Provided" scope" already
- This is not a maven project, I just load the jar as external library
- When editing, IntelliJ shows no error or warning
- I checked tons of Stackoverflow posts with the same topic but couldn't find anything useful
I'm wondering what could be the issue?
Edit:
IntelliJ warned me I'm instantiating a utility class and this mostly likely is an error. Since I'm a Java newbie, I Googled a bit and found out that maybe I could directly call VerifyApp.main(args)
without instantiating the object. This DOES pass the build, but I got a runtime error:
NoClassDefFoundError, caused by ClassNotFoundException
Now I'm out of trick.