-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
can't import other package #219
Comments
it is best to know how the code is being compiled - that is how janino is being used. Especially the differences between your production server and your computer are relevant - differences in the classpath here are noteworthy here (but even if there are no differences, knowing the classpath should be important either way) |
I referred to this code in your home page https://janino-compiler.github.io/janino/#janino-as-a-command-line-java-compiler :
and write my own code in this.Then found it can't import other package in production server ,can I add this |
Yes, you'd need to configure the classpath in order to be able to use dependencies. I cannot quite remember how janino handles the classpath as it has been a while since I last used it, but I surmise that the file array you wish to use would include files which are jars to directories which contain raw class files. But in order to be sure I'd read the documentation of the method ( janino/commons-compiler/src/main/java/org/codehaus/commons/compiler/ICompiler.java Lines 149 to 154 in 4db1b81
That being said, you don't need to include the source resources on the classpath. That is, for as long as you compile two (or more) classes together, you don't need to do anything if they depend on each other (but you can't easily compile them separately). |
What exactly do you mean with "GsonUtils which is a class in my own project"? Is there a .class file with that name, or is that class on the classpath of the currently running JVM? BTW, instead of concatenating Java code as in your code example, you should rather use |
Help!
I want to compile some java code which is String format,like this
but I found when icompiler compile this code ,"java.util.*" is ok,but the second line GsonUtils which is a class in my own project,can't find this class when I call this :" compiler.compile()" method. Actually,it can run in my own pc, but when this code deploy on a production server , " compiler.compile()" method will throw exception ,can't find this class.
what can i do ! help!
The text was updated successfully, but these errors were encountered: