compilation java javax.el.ExpressionFactory - java

i tried to compile a code, this class compiled and i broke someth
I search impossible to find this method and which jar miss
import javax.el.ExpressionFactory
org.apache.commons.jexl2.Expression e = ExpressionFactory.newInstance().createExpression;
i tried to add commons-jexl_2.1.1.jar and i hava this error
Multiple markers at this line
- The method createExpression(String) is undefined for the type
ExpressionFactory
i tried grepcode but it seem not recognized createExpression
Do you have any ideas?
Thanks

Related

java.lang.NoSuchFieldError: No static field MAXICODE of type Lcom/google/zxing/BarcodeFormat; in class Lcom/google/zxing/BarcodeFormat;

I want to implement library of barcode scanner from https://github.com/dm77/barcodescanner.
and I getting error after I run the project like this
java.lang.NoSuchFieldError: No static field MAXICODE of type Lcom/google/zxing/BarcodeFormat; in class Lcom/google/zxing/BarcodeFormat; or its >superclasses (declaration of 'com.google.zxing.BarcodeFormat' appears in /data/app/com.myPro.simantra-2/base.apk:classes3.dex)
at me.dm7.barcodescanner.zxing.ZXingScannerView.(ZXingScannerView.java:54)
at com.myPro.ActivityMainMenu.onCreate(ActivityMainMenu.java:226)
after I debug this I find the error is while code run at
mScannerView = new ZXingScannerView(this);
but if I make a new Project and implement this, it will running well.
This problem has been solved. the problem is in my old project/Library that Imported to current project I was compiled old
core.jar
that doesn't contain
MAXICODE in Lcom/google/zxing/BarcodeFormat class.
so to fix the problem just simply comment
implementation files('libs/jars/core.jar')
in gradle. Thank you

how to use Base64.getEncoder().encodeToString() and Base64.encodeBase64String() together in single file

I have a jsp file, in which I need to use to methods of class Base64.
one method is present in java.util :
java.util.Base64.getEncoder().encodeToString().
and another method is present in
org.apache.commons.codec.binary package :
org.apache.commons.codec.binary.Base64.encodeBase64String()
so to achieve this I used fully classified names but still it is givng error.
org.apache.jasper.JasperException: Unable to compile class for JSP: An
error occurred at line: 59 in the jsp file: /ProcessDetails.jsp
org.apache.commons.codec.binary.Base64 cannot be resolved to a type
56: String signature =
java.util.Base64.getEncoder().encodeToString(sha256_HMAC.doF‌​inal(data.getBytes()‌​));
59: String paymentToken =
org.apache.commons.codec.binary.Base64.encodeBase64String(sh‌​a256_HMAC.doFinal(da‌​ta.getBytes()));
Sounds like you might be missing either the apache commons jar in your WEB-INF/lib
see jsp "unable to compile" and "cannot be resolved to a type"
or perhaps a missing import statement in your JSP
see Unable to compile class for JSP: cannot be resolved to a type
Hope that helps

Scala: no corresponding Java Class found

While Compiling an Scala 2.10 Project, I got an error I cannot even understand
java.lang.NoClassDefFoundError: no Java class corresponding to MongoPersistable.this.type found
at scala.reflect.runtime.JavaMirrors$JavaMirror.typeToJavaClass(JavaMirrors.scala:1218) ~[scala-reflect-2.10.0.jar:na]
at scala.reflect.runtime.JavaMirrors$JavaMirror.runtimeClass(JavaMirrors.scala:202) ~[scala-reflect-2.10.0.jar:na]
at scala.reflect.runtime.JavaMirrors$JavaMirror.runtimeClass(JavaMirrors.scala:65) ~[scala-reflect-2.10.0.jar:na]
...
How is this even possible to get such a error message if the code got well in eclipse in first place?
Following line of Code produces this error:
trait MongoPersistable {
def save() {
val dao : MongoDAO[MongoPersistable.this.type] = MongoDAO[this.type];
....
I would upload more code if I know where to search

Exception in use of OpenCV

Following is code which i am running :
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
public class Main_Extraction
{
public static void main( String[] args )
{
System.loadLibrary( Core.NATIVE_LIBRARY_NAME );
Mat mat = Mat.eye( 3, 3, CvType.CV_8UC1 );
System.out.println( "mat = " + mat.dump() );
}
}
this code is having no compile time error.
but, it's giving me run-time exception which is :
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: <any>
at Main_Extraction.main(Main_Extraction.java:9) Java Result: 1
please, suggest the solution to remove this exception.
I had the same problem. Here is the solution, add this paths in your environment variable CLASSPATH. this will work.
C:\javacv\javacv.jar;
C:\javacv\javacpp.jar;
C:\javacv\javacv-windows-x86.jar;
C:\javacv\jna.jar;C:\javacv;
c:\opencv2.4\build\x86\vc10\bin;
set this according to your javacv installed folder.
You have attempted run a program that has compilation error in it. Fix the compilation errors BEFORE you try to run your program!!
this code is having no compile time error.
That is not true. The actual "compiled" bytecode file you are attempting to run is throwing an exception that says clearly that there was a compilation error of some kind.
Perhaps you are trying to compile a stale version ...
Perhaps you are compiling against a corrupted copy of the OpenCV JAR.
Perhaps you are using a buggy compiler ... and it crashed, giving you a bogus ".class" file.
Please check if the PATH variable is set correctly and opencv libraries are included, there is nothing wrong in the code.
Please follow this tutorial here for step by step installation of opencv in eclipse
http://nenadbulatovic.blogspot.de/2013/07/configuring-opencv-245-eclipse-cdt-juno.html

Java file not compiling

Currently trying to work with objects in Java. Everything goes fine until I hit compile. Have been reading a couple of other questions regarding the same problem, or the same given error, and at this point I am not sure wether I am forgetting something or that I need to change my classpath.
Main Class file:
package TesterClass;
public class Tester {
public static void main(String[] args){
TesterClass firstTest = new TesterClass();
firstTest.stringPrinter();
}
}
The file that is supposed to be functioning as a package file:
package TesterClass;
public class TesterClass{
private String workingSegment;
public TesterClass(){
workingSegment = "Working";
}
public void stringPrinter(){
System.out.println(workingSegment);
}
}
The 2 files are in the same directory and I am trying to manually compile them with
"javac Tester.java". The error I get is about the fact that its having issues with the package. All help is welcome!
EDIT: Forgot to post the actual compiler error.
Tester.java:9: cannot find symbol
symbol : class TesterClass
location: class TesterClass.Tester
TesterClass firstTest;
^
Tester.java:11: cannot find symbol
symbol : class TesterClass
location: class TesterClass.Tester
firstTest = new TesterClass();
^
2 errors
Move to the top of the source tree and compile both class...
So, assuming you source files are in \Java\TesterClass, you need to start in \Java
javac TesterClass\Tester.java TesterClass\TesterClass.java
You may also want to have a quick read of Code Conventions for the Java Programming Language as packages names are suppose to be in lower case :P
Updated
I just tried...
javac TesterClass\Tester.java
And it worked fine.
Are you sure that the Tester.java and TesterClass.java are in the TesterClass directory?
Updated with running example
So, basically, I dropped you .java files into the directory \compile under the TesterClass (\compile\TesterClass) directory and compiled them using...
\compile>javac TesterClass\Tester.java
Then I run them...
\compile>java TesterClass.Tester
Working
You need to go to the top of the directory hierarchy and first compile your TesterClass and then compile your Tester. Since you have not compiled your TesterClass yet, Tester is unable to find it.
The error clearly states that its not able to find the symbol TesterClass, and the reason being TesterClass hasn't been compiled yet.
I suggest you use an IDE which does the compilation automatically for you. If you stick to manual compilation, you need to compile all the classes in the proper order.
Try changing the package name so it does not match the class name. Right now they are the same. Make it package TesterClassPackage, then import TesterClass into the file with the main() method. Even though they are in the same package sometimes you need to literally import files even though they are in the same package.
javac TesterClass\TesterClass.java TesterClass\Tester.java
will do it

Categories