|
|
|
|
|
Re: ClassNotFoundException when two classes are defined in the same java file [message #32734 is a reply to message #32702] |
Wed, 15 July 2009 23:11 |
Pablo Passera Messages: 14 Registered: July 2009 |
Junior Member |
|
|
Hi David,
Thanks for your answer. Below I pasted the .java file that is giving
me that error. However, I tried also to compile J4ME and since it has some
files in where two classes are defined, I am getting the same error. Let
me know if you need more info.
I looked at the .mtj.tmp folder in the project and this is the
content of that dir:
mtj.tmp
SlideShow.jad
SlideShow.jar
verified
classes
SlideShow.class
SSCanvas.class
libs
The content of the SlideShow.jar file is:
META-INF
MANIFEST.MF
SlideShow.Class
pngtest16rgba.png
pnggrad8rgb.png
and the exact error is:
Running with storage root C:\Documents and
Settings\yo\j2mewtk\2.5.2\appdb\DefaultColorPhone
Running with locale: Spanish_Argentina.1252
Running in the identified_third_party security domain
java.lang.NoClassDefFoundError: SSCanvas
at com.sun.midp.midlet.MIDletState.createMIDlet(+29)
at com.sun.midp.midlet.Scheduler.schedule(+52)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+80)
Execution completed.
3405897 bytecodes executed
16 thread switches
1668 classes in the system (including system classes)
17652 dynamic objects allocated (529312 bytes)
2 garbage collections (458848 bytes collected)
------------------------------------------------------------ -----
//file: SlideShow.java
import java.io.IOException;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class SlideShow extends MIDlet implements CommandListener {
private Command exitCommand;
private Display display;
private SSCanvas screen;
public SlideShow() {
// Get the Display object for the MIDlet
display = Display.getDisplay(this);
// Create the Exit command
exitCommand = new Command("Exit", Command.EXIT, 2);
// Create the main screen form
screen = new SSCanvas();
// Set the Exit command
screen.addCommand(exitCommand);
screen.setCommandListener(this);
}
public void startApp() throws MIDletStateChangeException {
// Set the current display to the screen
display.setCurrent(screen);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}
class SSCanvas extends Canvas {
private Image[] slides;
private String[] captions = { "Automotive", "Beauty", "Construction",
"Pest Control", "Pet Store", "Restaurant" };
private int curSlide = 0;
public SSCanvas() {
// Load the slide show images
try {
slides = new Image[2];
slides[0] = Image.createImage("/pnggrad8rgb.png");
slides[1] = Image.createImage("/pngtest16rgba.png");
}
catch (IOException e) {
System.err.println("Failed loading images!");
}
}
public void keyPressed(int keyCode) {
// Get the game action from the key code
int action = getGameAction(keyCode);
// Process the left and right buttons
switch (action) {
case LEFT:
if (--curSlide < 0)
curSlide = slides.length - 1;
repaint();
break;
case RIGHT:
if (++curSlide >= slides.length)
curSlide = 0;
repaint();
break;
}
}
public void paint(Graphics g) {
// Clear the display
g.setColor(255, 255, 255); // White
g.fillRect(0, 0, getWidth(), getHeight());
// Draw the current image
g.drawImage(slides[curSlide], getWidth() / 2, getHeight() / 2,
Graphics.HCENTER | Graphics.VCENTER);
// Set the font for the caption
Font f = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD,
Font.SIZE_MEDIUM);
g.setFont(f);
// Draw the current caption
g.setColor(0, 0, 0); // Black
g.drawString(captions[curSlide], getWidth() / 2, 0,
Graphics.HCENTER | Graphics.TOP);
}
}
Regards,
Pablo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: ClassNotFoundException when two classes are defined in the same java file [message #575094 is a reply to message #32702] |
Wed, 15 July 2009 23:11 |
Pablo Passera Messages: 14 Registered: July 2009 |
Junior Member |
|
|
Hi David,
Thanks for your answer. Below I pasted the .java file that is giving
me that error. However, I tried also to compile J4ME and since it has some
files in where two classes are defined, I am getting the same error. Let
me know if you need more info.
I looked at the .mtj.tmp folder in the project and this is the
content of that dir:
mtj.tmp
SlideShow.jad
SlideShow.jar
verified
classes
SlideShow.class
SSCanvas.class
libs
The content of the SlideShow.jar file is:
META-INF
MANIFEST.MF
SlideShow.Class
pngtest16rgba.png
pnggrad8rgb.png
and the exact error is:
Running with storage root C:\Documents and
Settings\yo\j2mewtk\2.5.2\appdb\DefaultColorPhone
Running with locale: Spanish_Argentina.1252
Running in the identified_third_party security domain
java.lang.NoClassDefFoundError: SSCanvas
at com.sun.midp.midlet.MIDletState.createMIDlet(+29)
at com.sun.midp.midlet.Scheduler.schedule(+52)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+80)
Execution completed.
3405897 bytecodes executed
16 thread switches
1668 classes in the system (including system classes)
17652 dynamic objects allocated (529312 bytes)
2 garbage collections (458848 bytes collected)
------------------------------------------------------------ -----
//file: SlideShow.java
import java.io.IOException;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class SlideShow extends MIDlet implements CommandListener {
private Command exitCommand;
private Display display;
private SSCanvas screen;
public SlideShow() {
// Get the Display object for the MIDlet
display = Display.getDisplay(this);
// Create the Exit command
exitCommand = new Command("Exit", Command.EXIT, 2);
// Create the main screen form
screen = new SSCanvas();
// Set the Exit command
screen.addCommand(exitCommand);
screen.setCommandListener(this);
}
public void startApp() throws MIDletStateChangeException {
// Set the current display to the screen
display.setCurrent(screen);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}
class SSCanvas extends Canvas {
private Image[] slides;
private String[] captions = { "Automotive", "Beauty", "Construction",
"Pest Control", "Pet Store", "Restaurant" };
private int curSlide = 0;
public SSCanvas() {
// Load the slide show images
try {
slides = new Image[2];
slides[0] = Image.createImage("/pnggrad8rgb.png");
slides[1] = Image.createImage("/pngtest16rgba.png");
}
catch (IOException e) {
System.err.println("Failed loading images!");
}
}
public void keyPressed(int keyCode) {
// Get the game action from the key code
int action = getGameAction(keyCode);
// Process the left and right buttons
switch (action) {
case LEFT:
if (--curSlide < 0)
curSlide = slides.length - 1;
repaint();
break;
case RIGHT:
if (++curSlide >= slides.length)
curSlide = 0;
repaint();
break;
}
}
public void paint(Graphics g) {
// Clear the display
g.setColor(255, 255, 255); // White
g.fillRect(0, 0, getWidth(), getHeight());
// Draw the current image
g.drawImage(slides[curSlide], getWidth() / 2, getHeight() / 2,
Graphics.HCENTER | Graphics.VCENTER);
// Set the font for the caption
Font f = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_BOLD,
Font.SIZE_MEDIUM);
g.setFont(f);
// Draw the current caption
g.setColor(0, 0, 0); // Black
g.drawString(captions[curSlide], getWidth() / 2, 0,
Graphics.HCENTER | Graphics.TOP);
}
}
Regards,
Pablo
|
|
|
|
|
|
|
|
|
|
|
|