Lwuit class not found error.Please help me to solve it? - java-me

Im very new to "LWUIT" for "J2ME". I installed eclipse pulsar in my system.I also installed sony ericsson j2me sdk. The normal j2me is works fine.
When I use lwuit in my j2me project. Then it will not working.
I'm creating new project namely "lwuit2" in my eclipse pulsar.
Then I select my project from project or package explorer, then right clickt
Then I click libraries tab, then I click add external jar button,
then I choose the lwuit path where I store the lwuit.jar
then I click ok. It is success.
the following are my source code
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
public class TestMidlet1 extends MIDlet {
Form frm=null;
public TestMidlet1() {
// TODO Auto-generated constructor stub
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void startApp() throws MIDletStateChangeException {
// TODO Auto-generated method stub
Display.init(this);
frm=new Form("Testing lwuit");
frm.show();
}
}
When I type the above code the eclipse pulsar does not shows any compile time error. But when I run it, then it shows the error. I print screen the error window and attached it please refer the attachment below.

Pulsar does not export the lwuit.jar into your midlet's jar unless you instruct it to explicitly. On the "Order and Export" tab of the project's "Java Build Properties" select the lwuit.jar so that it is exported as part of your midlet.

Related

Lotus API getAllReadEntries throughs not implemented error in Eclipse

I am trying to get Read/Unread documents from Lotus notes, I can connect using this code:
package mypackage.Notes.GetRead;
import java.util.Vector;
import lotus.domino.Database;
import lotus.domino.NotesException;
import lotus.domino.NotesFactory;
import lotus.domino.Session;
import lotus.domino.View;
import lotus.domino.ViewEntryCollection;
public class GetRead {
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Session s = NotesFactory.createSession("192.168.32.156", "Administrator/MyOrg","password");
Database db = s.getDatabase("192.168.32.156", "\\mail\\administ.nsf");
//db.open();
View view = db.getView("($Inbox)");
ViewEntryCollection vec = view.getAllReadEntries();
System.out.println("View has " +
vec.getCount() + " read entries");
} catch (NotesException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
yet, I am getting:
NotesException: Not implemented
at lotus.domino.cso.Base.notImplemented(Unknown Source)
at lotus.domino.cso.View.getAllReadEntries(Unknown Source)
at sysgravity.Notes.GetRead.GetRead.main(GetRead.java:21)
I have made sure I am using the same notes.jar and NCSO.jar files as on the server, also tried to read Lotus Notes API giving error while accessing the NSF but not luck.
Is it realted to JDK version or eclipse version ?! what do I need to check ?!
EDIT WITH A SOLUTION:
Thanks Richard
for those who are struggling with this issue, here is the detailed solution:
As Richard have highlighted the getallreadentries is implemented in Notes.Jar and NOT NCSO.jar, and specifically it must be a local lotus call.
if you put a server address in the Notesfactory, Notes considers this a remote call and implement notes remote call not a local call through Notes.Jar and this is why you get troubles
the call must be local using:
NotesFactory.createSession((String)null, (String)null, password);
also you must use
- Java 32 bit for the JDK and JRE when running the jar.
- The computer that is running eclipse or your Jar must be running Lotus Admin + designer or has Notes client installed with the default notes.id properly configured (I found that having multiple notes IDs configured gives issues).
- Configure the PATH in your environment variables to point to Lotus Data File and Notes path.
then it will work.
Thanks, Mahmoud

Is there a way to run JBehave from with in main method like Cucumber's Main.run() method

I would like to initiate running of the BDD stories from with a Java's main method. Just like cucucumber's Main.run(), is there a similar way to specify JBehave configuration settings to a method and run it.
TIA
It can be done via extension of JUnitStory/JUnitStories and adding main method:
import org.jbehave.core.junit.JUnitStories;
public class MyStories extends JUnitStories {
// add configuration here
public static void main(String[] args) throws Throwable {
new MyStories().run();
}
}
Full example including full sample configuration can be found in the official JBehave repository: org/jbehave/examples/executable_jar/MyStories.java

How to get Liferay Authverifer working

I am implementing Liferay 6.2 AuthVerifier. I developed it but it does not get called that is, TestAuthVerifier.verify() method.
I referred https://docs.liferay.com/portal/6.2/propertiesdoc/portal.properties.html the link to develop tthe est AuthVerifer. Here is what I do below
I make entries in portal-ext.properties file as below and develop the class further.
auth.verifier.pipeline=com.test.TestAuthVerifier
auth.verifier.TestAuthVerifier.version.supported=1.0
my code is as below just for reference.
package comt.test;
import com.liferay.portal.security.auth.*;
public class TestAuthVerifier implements AuthVerifier {
#Override
public String getAuthType() {
return PhAuthVerifier.class.getSimpleName();
}
#Override
public AuthVerifierResult verify(
AccessControlContext accessControlContext, Properties properties)
throws AuthException {
System.out.println("MyAuthVerifier.verify() invoked..")
try {
.....
return authVerifierResult;
} catch (AutoLoginException e) {
throw new AuthException(e);
}
}
On debugging from Liferay 6.2.3 source code I see the point when
the flow is broken is AuthVerifierPipeline._mergeAuthVerifierConfiguration() method.
the statement : Map settings = accessControlContext.getSettings(); returns zero size map.
Finally the actual place where the Verifier is called : AuthVerifierPipeline._verifyRequest() does not run as List authVerifierConfigurations is ZERO size.
I looked in AccessControlContext class and other classes, I could not see any setter method to set _settings or any references which set this var.
any help around this is much appreciated.
note : I verified that LifeRay does recognize my TestAuthVerifier impl.
to make it work you have to work with the hook plugin. First create a file liferay-hook.xml in WEB-INF folder to override the portal.properties
<?xml version="1.0"?>
<!DOCTYPE hook PUBLIC "-//Liferay//DTD Hook 6.2.0//EN" "http://www.liferay.com/dtd/liferay-hook_6_2_0.dtd">
<hook>
<portal-properties>portal.properties</portal-properties>
</hook>
In the src folder put the file portal.properties or if you are using maven in the resource folder with the properties of the AuthVerifier in your case
auth.verifier.pipeline=com.test.TestAuthVerifier
auth.verifier.TestAuthVerifier.version.supported=1.0
This is a link of a sample in liferay git for more detail sample-authverifier-hook

Is JUnit really unable to find my test class in android studio?

I read the solution to How to run a simple JUnit4 test in Android Studio 1.1? and verified my gradle plugin version is greater than 1.1
Right Clicking my junit 4 test class and selecting run gives this error in android studio:
Cannot find class com.me.android.javamodule.MyTestClass
My android proj dir looks like:
In module "app":
src-->main
src-->test-->java-->com.me.android.working contains WorkingTest.java
src-->test-->java-->com.me.android.javamodule contains MyTestClass.java
"javamodule" is a regular java module that the app module depends on, it is a sibling to the "app" module.
I don't think the error is accurate because I copied "MyTestClass.java" into com.me.android.working, which contains WorkingTest.java, a Junit4 test that CAN run. Android Studio still complains with the same error.
Here is MyTestClass.java
package com.me.android.javamodule;
import org.junit.Before;
import org.junit.Test;
public class MyTestClass {
private Solver solver;
#Before
public void init() {
solver = new Solver();
}
#Test
public void testReverse() {
assertTrue(solver.parseStr("woof").equals("foow"));
}
}
This worked for me:
right click src and select New Directory, call it test
do the same for test and call it java
right click java and select New Package to create a new package like com.application. unit test can go here.

Opportunity to using native methods systemwide. How to call method or how it should be named?

I want to use one native library for a plurality of applications. Library has compiled through android build system and now located in /system/lib/. It can be loaded in application through System.LoadLibrary("libexample"). But method in library which should be declared like
JNIEXPORT jstring JNICALL Java_application1_MainActivity_method1
turning out unusable because library should be used by several applications. And of course this several applications have their own unique names. So I tried to named my method just like
JNIEXPORT jstring JNICALL method1
and call
public native String method1(String string);
But of course my application trying to find it as Java_application1_MainActivity_method1
How to call this method or how it should be named?
Updated:
I tried to use this(see post with green tick) tutorial to complete my project. I wrote
a library for using native method:
package com.example.mylib;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MyClass extends Activity {
public native static String MyMethod(String string);
static {
System.loadLibrary("nativeLibrary");
}
}
Then I trying to use it in my application:
// Some no interesting inclusions
import com.example.mylib.MyClass;
public class MainActivity extends ListActivity {
// Some no interesting code.
MyMethod(file.getAbsolutePath())
//Some no interesting code
}
And it working as I need! But now I confused that my import com.example.mylib.MyClass;
"never used" in eclipse. And if I will create image with this "Is Library" project the latest will no resolving. Any idea?
Yes, you can use the same JNI signature in many applications. Your class may not belong to the default package of the application, as defined in AndroidManifest.xml. So what?
Example:
Start with HelloJni sample from NDK (in Eclipse, use Import -> Android -> existing Android Code, and point to the ${android-ndk-root}/samples/hello-jni).
Build it and run on device or emulator.
Open a new Android Application project, call it TestCrossJni.
The package name for our app will be: test.cross.jni - no relation to com.example.hellojni!
Choose "Create Activity" -> create Blank Activity.
Add new Java class to this project (src/com/example/hellojni/HelloJni.java):
package com.example.hellojni;
public class HelloJni
{
public static String gets() {
return stringFromJNI();
}
/* A native method that is implemented by the
* 'hello-jni' native library, which is packaged
* with this application.
*/
private native String stringFromJNI();
/* this is used to load the 'hello-jni' library on application
* startup. The library has already been unpacked into
* /data/data/com.example.hellojni/lib/libhello-jni.so at
* installation time by the package manager.
*/
static {
System.load("/data/data/com.example.hellojni/lib/libhello-jni.so");
}
}
Edit res/layout/activity_main.xml: replace
line 12 android:text="#string/hello_world" />
with android:id="#+id/hello_world" />
In src/test/cross/jni/MainActivity.java, add the following after
line 12 setContentView(R.layout.activity_main);
((android.widget.TextView)findViewById(R.id.hello_world)).setText(com.example.hellojni.HelloJni.gets());
Profit!

Resources