Blackberry: Verificattion error when using Library project as External Jar - blackberry

I have created two Blackberry project in Blackberry Java Plug-in for Eclipse, i.e. MyProjectApp(set as application project) and MyProjectLib(set as Library project). Now I have created a simple MainScreen class like below:
public class SampleScreen extends MainScreen {
public SampleScreen (){
RichTextField topbar = new RichTextField("hello world");
add(topbar);
}
}
Now I export MyProjectLib as Jar file and add the same in MyProjectApp as external Jar. Now I want to fire the SampleScreen using this:
public class MyProjectMain extends UiApplication{
public static void main(String[] args) {
MyProjectMain theApp = new MyProjectMain();
theApp.enterEventDispatcher();
}
public LangHostMain(){
// Push a screen onto the UI stack for rendering.
pushScreen(new SampleScreen());
}
}
It is giving following error:
Module 'MyProjectApp' has verification errors.
Error starting MyProjectApp: Module 'MyProjectApp' has verification errors.
But if I moved the SampleScreen class to MyProjectApp, it is working fine. What is problem in exporting the Jar and use it? What type of Verification is needed?

There's a tool preverify.exe; it makes sure that bytecode is compatible with the BlackBerry platform.
BlackBerry rapc compiler uses java 1.3 bytecode format when it compiles the application to a cod file.
If you have created your jar file in different bytecode format, for instance via compiling with javac version 7.0, then this jar file won't pass the verification.
Try to compile your jar file with key to make it compatible with VM 1.3 bytecode,
Use -target 1.3 key-value combination for the java compiler to build your jar file.

In short, using jars in BlackBerry is a mess.
Your jar should be preverified. I've had so many problems in the past trying to do this with eclipse plugin that I usually do it using command line. Inside your JDE path, usually at:
C:\Program files\Research In Motion\BlackBerry JDE x.x.x\bin
There's a program called preverify. Once you preverify your jar, another preverified jar is created at the specified output directory. That is the file you should import in build path.

Related

Importing classes from jar file in grails

I have downloaded and copied the http-builder-0.5.0-RC2.jar to the lib folder of my grails project. I am using GGTS and see the jar in my lib folder when I open the project.
BuildConfig.groovy has the following line in the dependency section:
compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.5.0-RC2'
When I try to reference a class from the jar the I am getting a reference error indicating the class name cannot be resolved.
Is there something I am missing in regards to importing classes from a jar file? I am new to java / groovy and would appreciate some help. Thanks.
import groovyx.net.http.HTTPBuilder
This results in:
Groovy:unable to resolve class groovyx.net.http.HTTPBuilder
I have downloaded and copied the http-builder-0.5.0-RC2.jar to the lib folder of my grails project.
This should not be necessary, since HttpBuilder is in Maven Central. Just declare the dependency and let Grails download the JAR itself along with its transitive dependencies. You may also want to consider using a more recent version of HttpBuilder (0.5.0-RC2 is from 2009, at the time of writing the current release is 0.7.1).
Delete the JAR from your lib directory and try refreshing your Grails dependencies again.

Dart library / package keyword meaning?

Is Dart library exactly the same Java package ?
Is Dart package exactly the same Java library (JAR) ?
A package is a set of libraries which can for example be deployed to pub.dartlang.org. I guess this is similar to a jar file.
A library is one Dart script file with or without a name (or a set of Dart script files with part/part of) and is the boundary for privacy. Private members are only visible or accessible from within the same library.

Add .so File To Android Studio , Execution failed

I import a project from eclipse to Android Studio. in android studio works fine but no in Android studio.
I load my library here:
static {
try {
System.loadLibrary("opencv_java");
} catch (Exception e) {
// TODO: handle exception
}
}
And i have a folder in app/src/main/jni/armeabi-v7a/ libopencv_java.so
But android Studio says. Execution failed for tast ':app:compileDebugNdk'
which step I need to do?
i only need include one .so file in my proyect.
With Android Studio, you have to put your .so files inside jniLibs/(armeabi-v7a|x86|...) folder if you want them to be included inside your APK.
If you have files under jni folder, Android Studio will try to compile your sources using the NDK and an auto-generated Makefile, that's certainly this task that is currently failing with your project.

Using a 3rd party library inside a WebWorks Javascript extension?

Usually, when creating a WebWorks Javascript extension you export your source files into a JAR with the appropriate provisions (e.g. library.xml, *.java). Usually, 3rd party libraries are in a jar file with compiled java code. I included the 3rd party jar inside my custom extension. This creates a jar within a jar file structure. The Blackberry Widget packager (bbwp) opens up the jar and compiles the Java files to be used in your WebWorks application. Blackberry's Java compiler is unable to compile because the appropriate packages are not visible in the class-path at the time of compilation. The appropriate packages are in the 3rd party library jar included in the extensions jar. Does anyone know how to resolve this class-path issue? Do I need the 3rd party source files instead of a jar? Is there documentation on how the BlackBerry Widget Packager (bbwp) works?
Thanks in advance.
Follow the instructions "Use precompiled classes in an extension" listed in the following link. That should resolve the compilation issue.
Creating a JAR file that defines your extension

No definition found for exported static routine : .main(String args[])

we are executing of my .cod and .jad files on Blackberry JDE4.0.2 simulator7290. while building that project we are geting the folloewing warnings
Deleting C:\Program Files\Research In Motion\BlackBerry JDE 4.0.2\samples\com\rim\samples\device\BlackCard\BlackCard.cod.
Building BlackCard ...
C:\Program Files\Research In Motion\BlackBerry JDE 4.0.2\bin\rapc.exe -quiet import=..\..\..\..\..\..\lib\net_rim_api.jar codename=BlackCard BlackCard.rapc "C:\Program Files\Research In Motion\BlackBerry JDE 4.0.2\1[1].1\1.1\BlackCard.cod" "C:\Program Files\Research In Motion\BlackBerry JDE 4.0.2\1[1].1\1.1\BlackCard.jad"
Warning!: No entry points found
Warning!: No definition found for exported static routine: .main(String[])
BlackCard - no errors.
Build complete.
I´ve searched in many forums to resolve this problem. But found out a easy way to create a new BlackBerry Project without this Problem.
I have the Eclipse SDK Version: 3.7.0 includes BlackBerry SDK.
Answer:
Create BlackBerry project: (Menu) File->New->BlackBerry Project
Enter a project name.
Click "next".
Under the source tab window open "Details"
(if it is not open, click the arrow besides "Details")
Click "Add project '...' to build path"
Click "finish".
This works for me and I hope for you too ;)
Sorry for my english.
André Müller
Not a lot of context here - but it really looks like you dont have a main defined in your project.
Look at this support forum thread:
No definition found for exported static routine: .main(String[])
I just tried using an old JDK version, and was hit by this error. I would not mark this as solved. I am still trying to figure out how to change my class path, ala http://supportforums.blackberry.com/t5/Java-Development/No-definition-found-for-exported-static-routine-main-String/td-p/238814 "The reason was a misconfigured bin-path in the eclipse classpath. Eclipse generated the classfiles in an other location than the rapc compiler searched for them. Fixing the classpath did it. " Admittedly I am using BBEclipse on a mac :/

Resources