Java 3D help me !

I cannt build this source by jbuilder . Pls help me, it show this error , thanks alot
C:\WTK22\bin\preverify.exe -cldc -classpath "D:\mobile3d\M3G\classes;C:\WTK22\lib\mmapi.jar;C:\WTK22\lib\wma20.jar;C:\WTK22\lib\j2me-ws.jar;C:\WTK22\lib\jsr75.jar;C:\WTK22\lib\jsr082.jar;C:\WTK22\lib\jsr184.jar;C:\WTK22\lib\cldcapi11.jar;C:\WTK22\lib\midpapi20.jar;C:\WTK22\lib\cldcapi10.jar;C:\WTK22\lib\midpapi10.jar;C:\WTK22\lib\wma11.jar" -d "D:\mobile3d\M3G\preverified-classes" @"D:\mobile3d\M3G\preverified-classes\params"
ERROR: floating-point constants should not appear
Error preverifying class m3g.HandCanvas
------------------------------- SOURCE WITH 3 CLASS ------------------------
class 1 :
// HandDisplay.java
// Andrew Davison, [email protected], July 2004
/* Display a 3D model loaded as a series of coordinates.
The model can be moved and rotated around the y-axis.
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class HandDisplay extends MIDlet
public void startApp()
{ Display d = Display.getDisplay(this);
d.setCurrent( new HandCanvas(this) );
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
public void quitApp()
{ notifyDestroyed(); }
} // end of HandDisplay class
---- class 2 --------------------------------------------------------------------------------------------------------------------------------------------------------
// HandCanvas.java
// Andrew Davison, [email protected], July 2004
/* Display a 3D model.
The model can be moved left, right, up, down, forward, and back,
and rotated left/right around the y-axis.
Holding a key down causing key repetition, even in implementations
which don't support keyRepeated().
The model-specific data is located in the methods:
getVerts() : returns its vertices
getNormals() : returns its normals
getTexCoords() : returns its texture coordinates
getStripLengths() : returns an array containing the lengths of each
of the triangle strips in the shape
setMatColours() : sets the material colours and shininess
getColourCoords(): returns its colour coordinates
These methods are generated by the ObjView Java 3D application; they
can be copied over from the examObj.txt file that ObjView outputs.
The texture image filename should be placed in the TEX_FNM constant.
The camera's position may need to be adjusted, by changing the
X_CAMERA, Y_CAMERA, Z_CAMERA values.
import javax.microedition.lcdui.*;
import javax.microedition.m3g.*;
public class HandCanvas extends Canvas
implements CommandListener
private static final String TEX_FNM = "/r.gif";
// name of tex image file; change as required
private static final float X_CAMERA = 0.0f;
private static final float Y_CAMERA = 0.0f;
private static final float Z_CAMERA = 3.0f;
// camera coordinates; change as required
private static final float MODEL_MOVE = 0.2f;
// distance to move the model up/down/left/right/fwd/back for a key press
private static final float MODEL_ROT = 5.0f; // 5 degrees
// angle to rotate the model left/right for a key press
private HandDisplay top;
private Graphics3D g3d;
private Camera camera;
private Light light;
private Background bg;
private VertexBuffer vertBuf;
// holds the model's positions, normals, colors coords, and tex coords
private IndexBuffer idxBuf;
// indices to the model's triangle strips
private Appearance app;
private Transform camTrans, modelTrans;
// transforms used by the camera and the model
// model position and angle information
private float xTrans, yTrans, zTrans;
private int totalDegrees;
private KeyRepeat keyRepeater; // for repeating key presses
public HandCanvas(HandDisplay top)
this.top = top;
setCommandListener(this);
keyRepeater = new KeyRepeat(this);
keyRepeater.start();
try {
createScene();
catch (Exception e)
{ e.printStackTrace(); }
} // end of HandCanvas()
public void commandAction(Command c, Displayable d)
if (c.getCommandType() == Command.EXIT) {
keyRepeater.cancel();
keyRepeater = null;
top.quitApp();
} // end of commandAction()
private void createScene() throws Exception
addCommand( new Command("Exit", Command.EXIT, 1) );
g3d = Graphics3D.getInstance();
// create a camera
camera = new Camera();
float aspectRatio = ((float) getWidth()) / ((float) getHeight());
camera.setPerspective(45.0f, aspectRatio, 0.1f, 50.0f);
// was 60, aspectRatio, 1, 1000
// set up the camera's position
camTrans = new Transform();
camTrans.postTranslate(X_CAMERA, Y_CAMERA, Z_CAMERA);
// create a light
light = new Light();
light.setColor(0xffffff); // white light
light.setIntensity(1.25f); // over bright
// initialise the model's transform vars
modelTrans = new Transform();
xTrans = 0.0f; yTrans = 0.0f; zTrans = 0.0f;
totalDegrees = 0;
makeGeometry();
makeAppearance();
bg = new Background();
bg.setColor(0x9EFEFE); // light blue
} // end of createScene()
// ------------------- model creation -----------------------------
private void makeGeometry()
/* Read in the values for the vertices, normals, texture coords,
and colour coords, and create a VertexBuffer object. Also
read in the strip lengths array to create the index for the
triangle strips used in the vertex buffer.
Depending on the model, there may not be any texture or colour
coordinates, and so the calls related to them should be commented
out.
The texture coordinates can use 2, 3, or 4 components, and the
colour coordinates 3 or 4, which will require changes to the array
creation code. The code here assumes (s,t) format for texture coords
(2 components) and RGB for the colours (3 components), the most common
formats.
// create vertices
short[] verts = getVerts();
VertexArray va = new VertexArray(verts.length/3, 3, 2);
va.set(0, verts.length/3, verts);
// create normals
byte[] norms = getNormals();
VertexArray normArray = new VertexArray(norms.length/3, 3, 1);
normArray.set(0, norms.length/3, norms);
// create texture coordinates
short[] tcs = getTexCoordsRev();
VertexArray texArray = new VertexArray(tcs.length/2, 2, 2);
// this assumes (s,t) texture coordinates
texArray.set(0, tcs.length/2, tcs);
// create colour coordinates
short[] cols = getColourCoords();
VertexArray colsArray = new VertexArray(cols.length/3, 3, 2);
// this assumes RGB colour coordinates
colsArray.set(0, cols.length/3, cols);
// ------ create the VertexBuffer for the model -------
vertBuf = new VertexBuffer();
float[] pbias = {(1.0f/255.0f), (1.0f/255.0f), (1.0f/255.0f)};
vertBuf.setPositions(va, (2.0f/255.0f), pbias); // scale, bias
// fix the scale and bias to create points in range [-1 to 1]
vertBuf.setNormals(normArray);
// vertBuf.setTexCoords(0, texArray, (1.0f/255.0f), null);
// fix the scale to create texCoords in range [0 to 1]
// vertBuf.setColors(colsArray);
// create the index buffer for the model (this tells MIDP how to
// create triangle strips from the contents of the vertex buffer).
idxBuf = new TriangleStripArray(0, getStripLengths() );
} // end of makeGeometry()
private short[] getTexCoordsRev()
// Return an array of texture coords (s,t)
// with their t coords reversed.
// This method will need to be commented out if there are
// no textures used in the model.
short[] tcs = getTexCoords();
// t' = 255 - t (will later be scaled from 255 to 1)
for(int i=1; i < tcs.length; i=i+2)
tcs = (short)(255 - tcs);
return tcs;
} // end of getTexCoordsRev()
private void makeAppearance() throws Exception
/* Load the texture and material information into the Appearance
node.
Depending on the model, there may not be a texture image, and so
the texture-specific code here will need to be commented out.
The material colour and shininess data is obtained from
setMatColours().
// load the image for the texture
Image im = Image.createImage(TEX_FNM);
// create an Image2D for the Texture2D
Image2D image2D = new Image2D(Image2D.RGB, im);
// create the Texture2D and enable mip mapping
// the texture color is modulated with the lit material color
Texture2D tex = new Texture2D(image2D);
tex.setFiltering(Texture2D.FILTER_NEAREST, Texture2D.FILTER_NEAREST);
tex.setWrapping(Texture2D.WRAP_CLAMP, Texture2D.WRAP_CLAMP);
// tex.setWrapping(Texture2D.WRAP_REPEAT, Texture2D.WRAP_REPEAT);
tex.setBlending(Texture2D.FUNC_MODULATE);
// create the appearance
app = new Appearance();
// app.setTexture(0, tex);
app.setMaterial( setMatColours() );
} // end of makeAppearance()
// ------------------ paint the canvas ------------------
public void paint(Graphics g)
// bind the canvas graphic to our Graphics3D object
g3d.bindTarget(g, true, Graphics3D.DITHER | Graphics3D.TRUE_COLOR);
g3d.clear(bg); // clear the color and depth buffers
g3d.setCamera(camera, camTrans); // position the camera
// set up a "headlight": a directional light shining
// from the direction of the camera
g3d.resetLights();
g3d.addLight(light, camTrans);
updateModelTrans();
// Render the model. We provide the vertex and index buffers
// to specify the geometry; the appearance so we know what
// material and texture to use; and a tranform to position
// the model
g3d.render(vertBuf, idxBuf, app, modelTrans);
g3d.releaseTarget(); // flush
} // end of paint()
private void updateModelTrans()
// the model's transform = a translation * a rotation
modelTrans.setIdentity(); // reset
modelTrans.postTranslate(xTrans, yTrans, zTrans);
modelTrans.postRotate(totalDegrees, 0, 1, 0); // around y-axis
} // end of updateModelTrans()
// -----------------key operation methods ---------------------
public void keyRepeated(int keyCode)
int gameAction = getGameAction(keyCode);
if (hasRepeatEvents())
performAction( gameAction );
protected void keyPressed(int keyCode)
int gameAction = getGameAction(keyCode);
// System.out.println("Can repeat: " + hasRepeatEvents());
// if this MIDP doesn't support repeated keys
// then initialise our key repeater
if (!hasRepeatEvents())
keyRepeater.startRepeat( gameAction );
} // end of keyPressed()
protected void keyReleased(int keyCode)
int gameAction = getGameAction(keyCode);
// if this MIDP doesn't support repeated keys
// then stop our key repeater
if (!hasRepeatEvents())
keyRepeater.stopRepeat( gameAction );
public void performAction(int gameAction)
// called by KeyRepeat object or the keyRepeated() method
if (gameAction == UP) {
moveModel(0,MODEL_MOVE,0); // y up
else if (gameAction == DOWN) {
moveModel(0,-MODEL_MOVE,0); // y down
else if (gameAction == LEFT) {
moveModel(-MODEL_MOVE,0,0); // x left
else if (gameAction == RIGHT) {
moveModel(MODEL_MOVE,0,0); // x right
else if (gameAction == GAME_A) {
// System.out.println("fwd");
moveModel(0,0,MODEL_MOVE); // z fwd
else if (gameAction == GAME_B) {
// System.out.println("back");
moveModel(0,0,-MODEL_MOVE); // z back
else if (gameAction == GAME_C) {
// System.out.println("rot left");
rotYModel(-MODEL_ROT); // rotate left
else if (gameAction == GAME_D) {
// System.out.println("rot right");
rotYModel(MODEL_ROT); // rotate right
} // end of keyPressed()
private void moveModel(float x, float y, float z)
// update the model's translation values
{ xTrans += x; yTrans += y; zTrans += z;
repaint();
private void rotYModel(float degrees)
// update the model's y-axis rotation value
{ totalDegrees += degrees;
repaint();
} // end of rotYModel()
// ----------------- data-specific methods added here -------
The following methods can be pasted in from the ObjView application
output stored in examObj.txt:
private short[] getVerts() {...}
private byte[] getNormals() {...}
private short[] getTexCoords() (...}
private short[] getColourCoords() (...}
private int[] getStripLengths() {...}
private Material setMatColours() {...}
// Methods for model in hand.obj
private short[] getVerts()
// return an array holding Verts [2205 values / 3 = 735 points]
short[] vals = {
42,114,-5, 47,101,4, 52,114,-2, 47,101,4,
61,111,-1, 47,101,4, 57,99,4, 50,83,9,
57,99,4, 62,96,-2, 61,111,-1, 89,69,25,
87,72,30, 97,68,28, 96,71,35, 101,62,33,
83,69,38, 90,67,42, 87,72,30, 90,67,42,
96,71,35, 95,63,46, 96,71,35, 100,66,39,
101,62,33, 100,66,39, 101,56,38, 100,66,39,
100,58,43, 95,63,46, 100,58,43, 97,59,47,
92,51,49, 97,59,47, 87,55,49, 95,63,46,
87,55,49, 90,67,42, 82,58,46, 83,69,38,
77,61,42, 83,69,38, 77,69,34, 87,72,30,
79,70,28, 87,72,30, 82,69,24, 89,69,25,
82,69,24, 85,62,26, 82,69,24, 78,63,26,
79,70,28, 74,64,30, 77,69,34, 73,64,36,
77,61,42, 69,56,37, 77,61,42, 70,52,42,
82,58,46, 70,52,42, 74,48,46, 70,52,42,
64,43,40, 70,52,42, 64,46,35, 69,56,37,
70,57,32, 73,64,36, 70,57,32, 74,64,30,
70,57,32, 78,63,26, 74,55,28, 85,62,26,
79,51,27, 85,62,26, 91,58,29, 89,69,25,
91,58,29, 97,68,28, 91,58,29, 101,62,33,
95,53,34, 101,56,38, 95,49,40, 100,58,43,
94,49,45, 92,51,49, 87,40,46, 92,51,49,
84,42,49, 87,55,49, 79,45,49, 82,58,46,
79,45,49, 74,48,46, 71,37,46, 74,48,46,
67,40,43, 64,43,40, 67,40,43, 59,36,38,
67,40,43, 61,33,42, 67,40,43, 65,31,44,
71,37,46, 69,29,44, 71,37,46, 76,35,46,
79,45,49, 76,35,46, 84,42,49, 79,33,43,
87,40,46, 88,40,41, 94,49,45, 88,40,41,
95,49,40, 87,42,35, 95,53,34, 84,46,30,
91,58,29, 84,46,30, 79,51,27, 75,41,26,
79,51,27, 70,45,26, 74,55,28, 70,45,26,
70,57,32, 66,47,30, 64,46,35, 59,38,33,
64,43,40, 59,38,33, 59,36,38, 53,31,34,
59,36,38, 53,29,39, 61,33,42, 55,27,43,
65,31,44, 59,24,46, 65,31,44, 64,22,45,
69,29,44, 69,20,42, 69,29,44, 74,27,40,
76,35,46, 74,27,40, 79,33,43, 81,32,38,
88,40,41, 81,34,33, 87,42,35, 78,37,29,
84,46,30, 78,37,29, 75,41,26, 71,33,24,
75,41,26, 66,36,23, 70,45,26, 66,36,23,
66,47,30, 62,38,27, 59,38,33, 56,31,27,
53,31,34, 51,31,26, 44,26,35, 41,39,27,
30,29,29, 41,39,27, 31,51,20, 41,55,19,
31,51,20, 35,68,14, 27,65,9, 32,83,4,
27,65,9, 26,64,-1, 21,54,1, 26,64,-1,
29,61,-8, 34,79,-12, 29,61,-8, 39,61,-8,
36,45,-4, 45,51,2, 46,35,11, 47,41,19,
51,31,26, 47,41,19, 41,39,27, 47,41,19,
41,55,19, 47,41,19, 46,55,11, 45,51,2,
49,67,6, 45,51,2, 47,64,-3, 39,61,-8,
43,77,-12, 34,79,-12, 39,97,-16, 34,79,-12,
30,81,-5, 26,64,-1, 30,81,-5, 32,83,4,
37,102,-1, 32,83,4, 41,84,10, 35,68,14,
44,69,14, 41,55,19, 44,69,14, 46,55,11,
44,69,14, 49,67,6, 54,80,3, 49,67,6,
52,78,-6, 47,64,-3, 52,78,-6, 43,77,-12,
49,95,-16, 39,97,-16, 43,110,-17, 39,97,-16,
34,100,-9, 30,81,-5, 34,100,-9, 37,102,-1,
42,114,-5, 37,102,-1, 47,101,4, 41,84,10,
50,83,9, 44,69,14, 50,83,9, 54,80,3,
62,96,-2, 52,78,-6, 59,94,-10, 49,95,-16,
59,94,-10, 63,107,-13, 62,96,-2, 64,111,-7,
61,111,-1, 64,111,-7, 54,117,-11, 63,107,-13,
54,110,-17, 49,95,-16, 54,110,-17, 43,110,-17,
54,117,-11, 43,110,-17, 42,114,-12, 34,100,-9,
42,114,-12, 42,114,-5, 54,117,-11, 52,114,-2,
61,111,-1, 53,31,34, 44,26,35, 53,29,39,
45,20,42, 55,27,43, 49,17,46, 59,24,46,
53,14,48, 59,24,46, 58,12,48, 64,22,45,
64,9,44, 69,20,42, 68,8,38, 69,20,42,
73,19,36, 74,27,40, 77,26,35, 81,32,38,
77,26,35, 81,34,33, 77,27,31, 81,34,33,
75,29,27, 78,37,29, 75,29,27, 71,33,24,
66,25,23, 66,36,23, 61,28,23, 62,38,27,
61,28,23, 56,31,27, 52,23,19, 51,31,26,
52,23,19, 46,35,11, 37,24,4, 36,45,-4,
23,44,-6, 29,61,-8, 23,44,-6, 21,54,1,
17,64,-11, 18,67,-3, 15,86,-17, 18,67,-3,
18,89,-9, 14,91,-1, 14,112,-7, 3,111,-3,
13,124,-11, 3,111,-3, 3,126,-10, -7,122,-10,
3,126,-10, 3,127,-19, 13,124,-11, 15,125,-19,
13,124,-11, 18,110,-15, 14,112,-7, 18,110,-15,
18,89,-9, 15,107,-22, 15,86,-17, 15,107,-22,
5,106,-24, 14,121,-24, 4,121,-25, 14,121,-24,
3,127,-19, 14,121,-24, 15,125,-19, 14,121,-24,
18,110,-15, 15,107,-22, -21,90,15, -27,101,22,
-22,91,24, -29,90,31, -22,91,24, -17,76,25,
-21,90,15, -16,75,16, -21,90,15, -26,88,11,
-21,90,15, -28,101,16, -27,101,22, -38,102,22,
-27,101,22, -34,101,28, -29,90,31, -34,101,28,
-42,97,32, -38,102,22, -42,97,32, -46,97,28,
-44,85,30, -46,97,28, -47,94,22, -38,102,22,
-40,97,16, -28,101,16, -30,98,11, -26,88,11,
-30,98,11, -36,85,14, -40,97,16, -36,85,14,
-47,94,22, -44,84,22, -44,85,30, -37,70,29,
-44,85,30, -38,87,34, -42,97,32, -38,87,34,
-29,90,31, -38,87,34, -31,72,34, -37,70,29,
-29,52,28, -37,70,29, -37,68,21, -44,84,22,
-37,68,21, -36,85,14, -30,69,13, -26,88,11,
-21,72,11, -16,75,16, -21,72,11, -10,59,14,
-14,55,8, -5,51,10, -4,39,2, -5,51,10,
-1,62,-7, -4,65,2, -7,86,-6, -4,89,2,
-7,86,-6, -10,107,-12, -7,86,-6, -3,84,-15,
-1,62,-7, 8,61,-12, -1,62,-7, 10,36,-6,
-4,39,2, 10,36,-6, 12,5,1, 24,13,0,
26,-12,7, 40,6,11, 45,-5,17, 58,14,22,
63,10,26, 71,22,27, 63,10,26, 74,20,31,
63,10,26, 68,8,31, 57,-10,30, 60,-8,37,
52,-22,36, 60,-8,37, 47,-22,41, 56,-7,44,
47,-22,41, 50,-4,48, 41,-20,46, 44,-2,49,
35,-20,47, 44,-2,49, 31,-17,46, 40,0,47,
31,-17,46, 35,2,43, 25,-18,43, 35,2,43,
20,-11,39, 31,10,38, 20,-11,39, 19,17,29,
10,12,31, 19,17,29, 8,43,21, 20,49,15,
6,68,12, 15,69,7, 6,68,12, 5,91,4,
-4,89,2, -7,109,-5, -10,107,-12, -7,109,-5,
-7,122,-10, -7,109,-5, 3,111,-3, 5,91,4,
14,91,-1, 15,69,7, 18,67,-3, 15,69,7,
21,54,1, 20,49,15, 27,65,9, 20,49,15,
31,51,20, 20,49,15, 30,29,29, 19,17,29,
30,29,29, 31,10,38, 44,26,35, 31,10,38,
45,20,42, 35,2,43, 49,17,46, 40,0,47,
53,14,48, 44,-2,49, 53,14,48, 50,-4,48,
58,12,48, 56,-7,44, 64,9,44, 56,-7,44,
68,8,38, 60,-8,37, 68,8,38, 68,8,31,
73,19,36, 74,20,31, 77,26,35, 74,20,31,
77,27,31, 71,22,27, 75,29,27, 71,22,27,
66,25,23, 58,14,22, 61,28,23, 58,14,22,
52,23,19, 40,6,11, 37,24,4, 24,13,0,
23,44,-6, 10,36,-6, 23,44,-6, 8,61,-12,
17,64,-11, 8,61,-12, 6,84,-19, -3,84,-15,
-6,105,-20, -10,107,-12, -6,119,-23, -10,107,-12,
-8,122,-17, -7,122,-10, -8,122,-17, 3,127,-19,
-6,119,-23, 4,121,-25, -6,119,-23, 5,106,-24,
-6,105,-20, 5,106,-24, 6,84,-19, 15,86,-17,
17,64,-11, 12,-123,45, 12,-47,17, 14,-127,44,
16,-49,17, 17,-128,43, 20,-49,19, 20,-128,44,
20,-49,22, 21,-127,47, 20,-49,22, 20,-125,49,
18,-46,26, 17,-121,49, 15,-43,27, 17,-121,49,
12,-44,27, 15,-122,49, 10,-47,26, 12,-123,45,
10,-46,20, 12,-47,17, 5,-31,14, 12,-47,17,
19,-38,13, 16,-49,17, 19,-38,13, 20,-49,19,
33,-35,20, 20,-49,22, 30,-40,30, 18,-46,26,
24,-35,40, 15,-43,27, 15,-31,40, 12,-44,27,
6,-22,39, 12,-44,27, 0,-32,37, 10,-47,26,
-2,-35,33, 10,-47,26, -1,-38,24, 10,-46,20,
-1,-38,24, 5,-31,14, -1,-38,24, -8,-27,28,
-2,-35,33, -5,-25,37, 0,-32,37, -3,-17,40,
6,-22,39, 2,11,33, 6,-22,39, 13,-18,39,
15,-31,40, 20,-26,42, 24,-35,40, 27,-27,44,
24,-35,40, 32,-29,44, 24,-35,40, 38,-32,36,
30,-40,30, 46,-27,29, 33,-35,20, 50,-10,22,
33,-35,20, 27,-27,12, 19,-38,13, 17,-24,8,
5,-31,14, 0,2,6, 5,-31,14, -8,-20,19,
-8,-27,28, -14,-13,24, -8,-27,28, -13,-14,32,
-5,-25,37, -9,-13,39, -3,-17,40, -6,11,37,
2,11,33, -10,38,32, -3,45,23, -17,58,32,
-11,60,24, -17,58,32, -23,75,32, -17,58,32,
-24,55,33, -10,38,32, -17,35,33, -6,11,37,
-13,10,37, -9,-13,39, -18,8,31, -13,-14,32,
-18,8,31, -14,-13,24, -18,5,22, -14,-13,24,
-11,3,14, -8,-20,19, -11,3,14, 0,2,6,
-11,3,14, -16,31,11, -18,5,22, -23,30,20,
-18,8,31, -23,32,29, -13,10,37, -23,32,29,
-17,35,33, -23,32,29, -24,55,33, -29,52,28,
-24,55,33, -31,72,34, -23,75,32, -29,90,31,
-23,75,32, -17,76,25, -11,60,24, -16,75,16,
-11,60,24, -10,59,14, -3,45,23, -5,51,10,
-2,67,11, -4,65,2, -2,67,11, -4,89,2,
-2,67,11, 6,68,12, -3,45,23, 8,43,21,
2,11,33, 10,12,31, 13,-18,39, 20,-11,39,
20,-26,42, 25,-18,43, 27,-27,44, 31,-17,46,
27,-27,44, 35,-20,47, 32,-29,44, 41,-20,46,
38,-32,36, 47,-22,41, 46,-27,29, 52,-22,36,
46,-27,29, 57,-10,30, 50,-10,22, 63,10,26,
50,-10,22, 45,-5,17, 27,-27,12, 26,-12,7,
17,-24,8, 12,5,1, 0,2,6, -4,39,2,
-16,31,11, -23,52,12, -16,31,11, -29,51,20,
-23,30,20, -29,51,20, -23,32,29, -29,51,20,
-29,52,28, -29,51,20, -37,68,21, -23,52,12,
-30,69,13, -23,52,12, -21,72,11, -23,52,12,
-14,55,8, -23,52,12, -4,39,2 };
return vals;
} // end of getVerts()
private byte[] getNormals()
// return an array holding Normals [2205 values / 3 = 735 points]
byte[] vals = {
-69,95,51, -17,51,116, -4,100,79, -17,51,116,
66,68,87, -17,51,116, 62,17,111, 61,8,112,
62,17,111, 122,-29,28, 66,68,87, 33,41,-117,
-3,127,-8, 79,58,-82, 64,109,19, 114,-3,-59,
-33,101,72, -10,95,85, -3,127,-8, -10,95,85,
64,109,19, 47,73,94, 64,109,19, 114,48,34,
114,-3,-59, 114,48,34, 120,-43,-14, 114,48,34,
112,-16,59, 47,73,94, 112,-16,59, 64,23,109,
62,-31,108, 64,23,109, -9,33,123, 47,73,94,
-9,33,123, -10,95,85, -43,53,109, -33,101,72,
-65,70,85, -33,101,72, -68,105,29, -3,127,-8,
-74,94,-46, -3,127,-8, -34,61,-107, 33,41,-117,
-34,61,-107, 8,-25,-125, -34,61,-107, -69,18,-106,
-74,94,-46, -102,63,-45, -68,105,29, -103,73,25,
-65,70,85, -107,60,37, -65,70,85, -84,46,85,
-43,53,109, -84,46,85, -62,27,108, -84,46,85,
-95,49,71, -84,46,85, -113,60,10, -107,60,37,
-101,50,-61, -103,73,25, -101,50,-61, -102,63,-45,
-101,50,-61, -69,18,-106, -39,11,-122, 8,-25,-125,
24,-13,-125, 8,-25,-125, 51,-42,-110, 33,41,-117,
51,-42,-110, 79,58,-82, 51,-42,-110, 114,-3,-59,
78,-64,-80, 120,-43,-14, 101,-78,-15, 112,-16,59,
97,-67,50, 62,-31,108, 77,-79,66, 62,-31,108,
22,-44,118, -9,33,123, -32,5,124, -43,53,109,
-32,5,124, -62,27,108, -37,-5,123, -62,27,108,
-69,32,103, -95,49,71, -69,32,103, -87,71,62,
-69,32,103, -60,57,98, -69,32,103, -25,25,123,
-37,-5,123, 28,-29,121, -37,-5,123, 12,-56,115,
-32,5,124, 12,-56,115, 22,-44,118, 67,-87,65,
77,-79,66, 98,-83,-2, 97,-67,50, 98,-83,-2,
101,-78,-15, 89,-60,-70, 78,-64,-80, 64,-38,-104,
51,-42,-110, 64,-38,-104, 24,-13,-125, 46,4,-120,
24,-13,-125, -28,36,-120, -39,11,-122, -28,36,-120,
-101,50,-61, -85,60,-75, -113,60,10, -103,75,-15,
-95,49,71, -103,75,-15, -87,71,62, -72,106,9,
-87,71,62, -68,83,70, -60,57,98, -49,63,100,
-25,25,123, -11,39,122, -25,25,123, 42,3,121,
28,-29,121, 83,-29,93, 28,-29,121, 75,-65,81,
12,-56,115, 75,-65,81, 67,-87,65, 97,-82,19,
98,-83,-2, 106,-51,-51, 89,-60,-70, 83,-22,-95,
64,-38,-104, 83,-22,-95, 46,4,-120, 51,-3,-118,
46,4,-120, -17,32,-123, -28,36,-120, -17,32,-123,
-85,60,-75, -76,61,-84, -103,75,-15, -50,94,-71,
-72,106,9, 64,111,5, -42,88,83, 30,64,107,
-39,51,111, 30,64,107, -35,52,111, 54,43,108,
-35,52,111, -36,47,114, -100,55,57, -103,44,62,
-100,55,57, -120,33,-29, 17,119,-45, -120,33,-29,
-58,0,-114, -63,-8,-111, -58,0,-114, 43,-38,-115,
56,-35,-110, 116,-26,-48, 115,0,-57, 119,35,32,
64,111,5, 119,35,32, 30,64,107, 119,35,32,
54,43,108, 119,35,32, 122,5,39, 116,-26,-48,
123,-31,16, 116,-26,-48, 101,-46,-65, 43,-38,-115,
34,-38,-117, -63,-8,-111, -60,-4,-113, -63,-8,-111,
-123,24,-26, -120,33,-29, -123,24,-26, -103,44,62,
-96,50,69, -103,44,62, -30,43,117, -36,47,114,
71,12,106, 54,43,108, 71,12,106, 122,5,39,
71,12,106, 123,-31,16, 115,-38,41, 123,-31,16,
101,-55,-56, 101,-46,-65, 101,-55,-56, 34,-38,-117,
32,-30,-120, -60,-4,-113, -40,46,-113, -60,-4,-113,
-117,41,-30, -123,24,-26, -117,41,-30, -96,50,69,
-69,95,51, -96,50,69, -17,51,116, -30,43,117,
61,8,112, 71,12,106, 61,8,112, 115,-38,41,
122,-29,28, 101,-55,-56, 94,-49,-72, 32,-30,-120,
94,-49,-72, 96,8,-84, 122,-29,28, 116,54,1,
66,68,87, 116,54,1, 26,121,-33, 96,8,-84,
31,37,-119, 32,-30,-120, 31,37,-119, -40,46,-113,
26,121,-33, -40,46,-113, -74,96,-40, -117,41,-30,
-74,96,-40, -69,95,51, 26,121,-33, -4,100,79,
66,68,87, -72,106,9, -42,88,83, -68,83,70,
-66,63,90, -49,63,100, -52,49,106, -11,39,122,
-17,23,125, -11,39,122, 39,-4,122, 42,3,121,
80,-26,97, 83,-29,93, 109,-49,46, 83,-29,93,
112,-52,35, 75,-65,81, 111,-63,14, 97,-82,19,
111,-63,14, 106,-51,-51, 105,-50,-53, 106,-51,-51,
82,-28,-94, 83,-22,-95, 82,-28,-94, 51,-3,-118,
37,-15,-122, -17,32,-123, -12,37,-122, -76,61,-84,
-12,37,-122, -50,94,-71, 68,33,-103, 64,111,5,
68,33,-103, 115,0,-57, 69,-28,-104, 56,-35,-110,
25,-15,-125, -58,0,-114, 25,-15,-125, 17,119,-45,
91,-7,-90, 127,14,4, 88,-20,-91, 127,14,4,
127,2,5, 90,29,86, 92,30,84, 12,47,119,
68,82,71, 12,47,119, -4,99,82, -78,76,68,
-4,99,82, -14,122,-35, 68,82,71, 94,85,-19,
68,82,71, 127,16,1, 92,30,84, 127,16,1,
127,2,5, 93,-15,-87, 88,-20,-91, 93,-15,-87,
-1,-22,-126, 66,39,-103, -12,42,-121, 66,39,-103,
-14,122,-35, 66,39,-103, 94,85,-19, 66,39,-103,
127,16,1, 93,-15,-87, 113,50,-34, 77,95,38,
107,48,51, 56,40,108, 107,48,51, 111,40,50,
113,50,-34, 112,41,-46, 113,50,-34, 36,19,-121,
113,50,-34, 44,100,-67, 77,95,38, -39,122,-10,
77,95,38, 23,100,77, 56,40,108, 23,100,77,
-35,64,105, -39,122,-10, -35,64,105, -106,59,41,
-107,-27,65, -106,59,41, -117,18,-50, -39,122,-10,
-62,64,-92, 44,100,-67, -13,48,-118, 36,19,-121,
-13,48,-118, -69,-17,-107, -62,64,-92, -69,-17,-107,
-117,18,-50, -114,-46,-35, -107,-27,65, -101,-49,62,
-107,-27,65, -32,-4,124, -35,64,105, -32,-4,124,
56,40,108, -32,-4,124, -23,-12,125, -101,-49,62,
-104,-44,61, -101,-49,62, -109,-46,-49, -114,-46,-35,
-109,-46,-49, -69,-17,-107, -60,-19,-112, 36,19,-121,
28,19,-124, 112,41,-46, 28,19,-124, 103,63,-42,
21,48,-117, -88,78,-51, -63,-5,-111, -88,78,-51,
-104,-27,-70, -128,-4,9, -127,-18,-7, -92,20,86,
-127,-18,-7, -128,-4,-5, -127,-18,-7, -91,-35,-84,
-104,-27,-70, -18,-35,-122, -104,-27,-70, -28,-32,-121,
-63,-5,-111, -28,-32,-121, -21,-29,-123, 34,-28,-120,
44,-31,-116, 70,-21,-105, 70,-28,-103, 58,-15,-113,
80,-38,-92, 75,-41,-96, 80,-38,-92, 105,-56,-46,
80,-38,-92, 108,-55,-40, 99,-56,-60, 109,-63,24,
97,-84,10, 109,-63,24, 71,-77,74, 78,-46,90,
71,-77,74, 35,-26,121, 34,-55,111, -17,2,127,
-11,-25,125, -17,2,127, -50,12,117, -53,29,113,
-50,12,117, -62,37,106, -54,16,115, -62,37,106,
-41,31,117, -56,49,104, -41,31,117, -19,46,118,
6,37,122, -19,46,118, 25,44,118, -4,66,110,
15,50,117, 94,42,76, 15,50,117, 14,41,120,
-92,20,86, -73,31,101, -128,-4,-5, -73,31,101,
-78,76,68, -73,31,101, 12,47,119, 14,41,120,
90,29,86, 94,42,76, 127,14,4, 94,42,76,
17,119,-45, -4,66,110, -100,55,57, -4,66,110,
-35,52,111, -4,66,110, -39,51,111, -19,46,118,
-39,51,111, -56,49,104, -42,88,83, -56,49,104,
-66,63,90, -62,37,106, -52,49,106, -53,29,113,
-17,23,125, -17,2,127, -17,23,125, 35,-26,121,
39,-4,122, 78,-46,90, 80,-26,97, 78,-46,90,
109,-49,46, 109,-63,24, 109,-49,46, 108,-55,-40,
112,-52,35, 105,-56,-46, 111,-63,14, 105,-56,-46,
105,-50,-53, 75,-41,-96, 82,-28,-94, 75,-41,-96,
37,-15,-122, 58,-15,-113, -12,37,-122, 58,-15,-113,
68,33,-103, 70,-21,-105, 69,-28,-104, 34,-28,-120,
25,-15,-125, -28,-32,-121, 25,-15,-125, -18,-35,-122,
91,-7,-90, -18,-35,-122, -8,-34,-123, -91,-35,-84,
-77,-29,-98, -128,-4,-5, -78,25,-98, -128,-4,-5,
-106,67,-25, -78,76,68, -106,67,-25, -14,122,-35,
-78,25,-98, -12,42,-121, -78,25,-98, -1,-22,-126,
-77,-29,-98, -1,-22,-126, -8,-34,-123, 88,-20,-91,
91,-7,-90, -127,-9,-11, -74,-38,-98, -64,-36,-105,
2,-41,-121, 22,-39,-120, 81,-49,-87, 111,-19,-61,
119,-43,18, 127,5,11, 119,-43,18, 98,25,78,
49,-43,110, 14,35,122, 3,-48,119, 14,35,122,
-24,-34,121, -88,21,90, -92,-59,67, -127,-9,-11,
-108,-53,-43, -74,-38,-98, -70,-49,-96, -74,-38,-98,
17,-46,-119, 2,-41,-121, 17,-46,-119, 81,-49,-87,
83,-72,-66, 119,-43,18, 64,-105,36, 49,-43,110,
-3,-81,99, 3,-48,119, -24,-50,115, -24,-34,121,
-5,-15,127, -24,-34,121, -15,-59,113, -92,-59,67,
-86,-80,51, -92,-59,67, -97,-78,-29, -108,-53,-43,
-97,-78,-29, -70,-49,-96, -97,-78,-29, -112,-62,-12,
-86,-80,51, -84,-50,83, -15,-59,113, -1,-5,127,
-5,-15,127, 34,31,119, -5,-15,127, -15,19,126,
-24,-50,115, -36,-5,123, -3,-81,99, -33,-27,121,
-3,-81,99, 21,-72,104, -3,-81,99, 60,-95,61,
64,-105,36, 89,-90,-22, 83,-72,-66, 80,-43,-90,
83,-72,-66, 56,-41,-108, 17,-46,-119, -6,-38,-122,
-70,-49,-96, -58,-29,-111, -70,-49,-96, -88,-50,-79,
-112,-62,-12, -118,-40,-30, -112,-62,-12, -116,-41,36,
-84,-50,83, -69,-14,107, -1,-5,127, 15,19,126,
34,31,119, 45,24,117, 56,61,98, 65,24,107,
110,45,47, 65,24,107, 61,23,110, 65,24,107,
-20,-9,126, 45,24,117, -29,5,125, 15,19,126,
-63,2,112, -69,-14,107, -120,-21,39, -116,-41,36,
-120,-21,39, -118,-40,-30, -117,-27,-45, -118,-40,-30,
-88,-29,-89, -88,-50,-79, -88,-29,-89, -58,-29,-111,
-88,-29,-89, -86,-24,-92, -117,-27,-45, -121,-31,-27,
-120,-21,39, -109,-25,63, -63,2,112, -109,-25,63,
-29,5,125, -109,-25,63, -20,-9,126, -104,-44,61,
-20,-9,126, -23,-12,125, 61,23,110, 56,40,108,
61,23,110, 111,40,50, 110,45,47, 112,41,-46,
110,45,47, 103,63,-42, 56,61,98, -88,78,-51,
-97,36,76, -128,-4,9, -97,36,76, -92,20,86,
-97,36,76, 15,50,117, 56,61,98, 25,44,118,
34,31,119, 6,37,122, -15,19,126, -41,31,117,
-36,-5,123, -54,16,115, -33,-27,121, -50,12,117,
-33,-27,121, -11,-25,125, 21,-72,104, 34,-55,111,
60,-95,61, 71,-77,74, 89,-90,-22, 97,-84,10,
89,-90,-22, 99,-56,-60, 80,-43,-90, 80,-38,-92,
80,-43,-90, 70,-28,-103, 56,-41,-108, 44,-31,-116,
-6,-38,-122, -21,-29,-123, -58,-29,-111, -63,-5,-111,
-86,-24,-92, -72,-16,-105, -86,-24,-92, -116,-40,-37,
-121,-31,-27, -116,-40,-37, -109,-25,63, -116,-40,-37,
-104,-44,61, -116,-40,-37, -109,-46,-49, -72,-16,-105,
-60,-19,-112, -72,-16,-105, 28,19,-124, -72,-16,-105,
21,48,-117, -72,-16,-105, -63,-5,-111 };
return vals;
} // end of getNormals()
private int[] getStripLengths()
// return an array holding the lengths of each triangle strip
int[] lens = {
11, 5, 257, 77, 199, 186
return lens;
} // end of getStripLengths()
private Material setMatColours()
// set the material's colour and shininess values
Material mat = new Material();
mat.setColor(Material.AMBIENT, 0x00765D4D);
mat.setColor(Material.EMISSIVE, 0x00000000);
mat.setColor(Material.DIFFUSE, 0xFF876A56);
mat.setColor(Material.SPECULAR, 0x004D4D4D);
mat.setShininess(60.0f);
return mat;
} // end of setMatColours()
} // end of HandCanvas class
-- class 3 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
// KeyRepeat.java
// Andrew Davison, [email protected], July 2004
/* Repeat key presses. The repetition speed is slow at first
then speeds up after a certain amount of time.
Based on ideas from the article:
"Using the Low-level GUI - Repeating Keys"
Roman Bialach, microdevnet, August 2001
http://www.microjava.com/articles/techtalk/repeating
import javax.microedition.lcdui.*;
public class KeyRepeat extends Thread
p

Hi,
I hope your problem is solved within the thread at http://forum.java.sun.com/thread.jspa?threadID=577857. Anyway, there are Java 3D examples bundled with latest netBeans Mobility Pack (see http://www.netbeans.info/downloads/download.php?type=rc2&p=1 for both netBeans 4.0 RC2 and said Mobility Pack). These will give you overview of what can and can't be done using Java 3D.
Peter

Similar Messages

  • Java Access Helper Jar file problem

    I just downloaded Java Access Helper zip file, and unzipped, and run the following command in UNIX
    % java -jar jaccesshelper.jar -install
    I get the following error message, and the installation stopped.
    Exception in thread "main" java.lang.NumberFormatException: Empty version string
    at java.lang.Package.isCompatibleWith(Package.java:206)
    at jaccesshelper.main.JAccessHelperApp.checkJavaVersion(JAccessHelperApp.java:1156)
    at jaccesshelper.main.JAccessHelperApp.instanceMain(JAccessHelperApp.java:159)
    at JAccessHelper.main(JAccessHelper.java:39)
    If I try to run the jar file, I get the same error message.
    Does anyone know how I can fix this?
    Thanks

    Cross-posted, to waste yours and my time...
    http://forum.java.sun.com/thread.jsp?thread=552805&forum=54&message=2704318

  • Java Access Helper problem

    I just downloaded Java Access Helper zip file, and unzipped, and run the following command in UNIX
    % java -jar jaccesshelper.jar -install
    I get the following error message, and the installation stopped.
    Exception in thread "main" java.lang.NumberFormatException: Empty version string
    at java.lang.Package.isCompatibleWith(Package.java:206)
    at jaccesshelper.main.JAccessHelperApp.checkJavaVersion(JAccessHelperApp.java:1156)
    at jaccesshelper.main.JAccessHelperApp.instanceMain(JAccessHelperApp.java:159)
    at JAccessHelper.main(JAccessHelper.java:39)
    If I try to run the jar file, I get the same error message.
    Does anyone know how I can fix this?
    Thanks

    sorry ab the multiple post, it was urgent for me to
    know the answer.
    I've JDK 1.4.2 and JAccessHelper should work with 1.3
    or later
    Can there be some kind of path problems?No, I doubt it. It's just some internal app failure - looks like it's trying to determine the running Java version, and is not doing a good job at it. But the failure has nothing per se to Java, it's that specific app - what are we supposed to know about that app though?

  • New to java(need help on access specifier)

    hi! i am new to java.plzzzzz help me i have to make a project on access specifier's i know all theroy.but
    i am unable to understand how i can define all specifiers practicly.i mean in a program.
    thanks.plzzzzzzzz help me

    the most common project i can think of is a payroll system..
    you can have real implementation of all the access specifiers
    good luck

  • Pascal to Java Please help me!

    I am truobled in creating a validation method for the user loging in....
    As I am perfect at Pascal can anyone translate the following pascla code to Java Please help me with this.
    PROGRAM USERLOGIN;
    TYPE
      USER_TYPE = RECORD
        USERNAME : STRING[15];
        PASSWORD : STRING[15];
    END;
        USFILE = FILE OF USER_TYPE;
    VAR
       USER: USER_TYPE;
       CKUSER: USER_TYPE;
       RECFILE : USFILE;
       I,J     : INTEGER;
    BEGIN
    WRITE('ENTER USERNAME:');READLN(CKUSER.USERNAME);
    WRITE('ENTER PASSWORD:');READLN(CKUSER.PASSWORD);
    FILESPEC :='USERFILE.USR';
    ASSIGN(RECFILE, FILESPEC);
    RESET(RECFILE);
      WHILE NOT EOF(RECFILE) DO
       BEGIN
         READ(RECFILE, USER);
         IF CKUSER.USERNAME = USER.USERNAME AND CKUSER.PASSWORD = USER.PASSWORD THEN
              LOGIN
        ELSE
              WRITE('USER NOT FOUND');
       END;
    END.Thank you

    Don't bother:
    http://forum.java.sun.com/thread.jsp?forum=54&thread=539277

  • How I can enable Java ssv helper plugin silently for win7 users with IE9

    here is what happens:
    when I deploy java 7.21 on win7 users, after deployment when users try to Open their IE they get a login screen and apparently it is related to Java ssv helper plugin. it is trying to enable it and needs admin account/password. I am trying to deploy this to about 3000 computers and I dont want all of them start calling helpdesk for this.
    your help is appreciated.

    The following article describes how to create a shared preference file. You can either create preferences that individual users can override, or create locked preferences that individual users cannot override.
    http://kb.mozillazine.org/Lock_Prefs
    (Note: I don't have any personal experience with these files, but another volunteer might post some additional tips and tricks.)

  • MS Access and Java JDBC help!

    Hello, I having trouble with a java GUI.
    I have a MS Access named Database.mdb with a table named Customer which I want my GUI to access.
    I want my GUI to be able to flick through the records using the field I have made for them.
    I already have connected the database using windows xp's "System DSN" and have no problem creating tables using sql statements in my code
    Who can help me? any information would be great.
    Thanks

    I'm doing an inventory software application too...but my application is an automatic software inventory, is automatic your application??
    My result is the software that are intalled in a machine..is your project too?
    Sorry, my english is not very good...

  • Why the same name of process comes out in AIX , in java. please help me.

    Hello.
    I have two questions related to Jvm.
    I've developed Job scheduler program which is doing somthing as the DB schedule is set in the way of Multi
    thread. Currently , I'm in the process of testing this one. It is good , if in the normal case. However, When
    doing Shell, if the application have so a lot to do the Shell, it has a little problem.
    My developing environment is
    OS : AIX 5.3
    JRE : IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 AIX ppc-32 jvmap3260sr7-20091214_49398
    (JIT enabled, AOT enabled)
    nofiles(descriptors) 2000
    maxuproc 4096 Maximum number of PROCESSES allowed
    per user True
    In order to execute Shell in My Scheduler program , I tested Runtimeexec() or ProcessBuilder.
    The result of mine in the test , when the executed Shell got over 300 is
         1. The jvm processes that I execute at the first time are shown up , after Shell go to the finish, the
    processes are all in the disappearance again , and at last The processes that I executed at the first time are
    remaining. It's like the process is duplicated process in the maximum of 70.
    When I do shell about 200 to be executed simultaneously, Duplicated jvm about 3 appeared momentarily, then
    disappeared, and also under 120, No duplicated case is found when under 120.
    ps -ef result is below , when shell is excuted
    UID PID PPID C STIME TTY TIME CMD
    jslee 626906 1 0 11, May - 2:20 java -
    DD2_JC_HOME=/source/jslee/JOB -Dfile.encoding=euc-kr jobserver.JobServerMain
    jslee 1421522 626906 0
    19:36:16 - 0:00 java -DD2_JC_HOME=/source/jslee/JOB -Dfile.encoding=euc-kr jobserver.JobServerMain
    ....Skip.....
    jslee 4374620 626906 0 19:34:06 - 0:00 java -DD2_JC_HOME=/source/jslee/JOB -
    Dfile.encoding=euc-kr jobserver.JobServerMain
    (the process list about 60)
    *the first question : Why a lot of duplicated jvm are shown up when in alot of shell to be executed ?
    *the second question : As you can see above , How can I solve out the problem.
    *Is there some option that I can set up when starting Jvm?
    ---Next question---
    My developing environment is
    OS : SunOS 5.8
    JRE : Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
    Java HotSpot(TM) Server
    VM (build 16.0-b13, mixed mode)
    nofiles(descriptors) 256
    As shown obove , the value of descriptors is 256 .
         My scheduler program executed 300 shell at the same time, in result my program was abnormalily
    terminated after doing shell about 180.
    the Exception info is
    java.io.IOException: Cannot run program "sh": error=24, exceeding the number of opened files
         at
    java.lang.ProcessBuilder.start(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
         at
    java.lang.Runtime.exec(Unknown Source)
         at java.lang.Runtime.exec(Unknown Source)
    or
    java.net.SocketException: exceeding the number of opened files     at java.net.PlainSocketImpl.socketAccept
    (Native Method)
    &#46608;&#45716;
    java.io.IOException: exceeding the number of opened files     at
    java.io.UnixFileSystem.createFileExclusively(Native Method)
         at java.io.File.checkAndCreate(Unknown
    Source)
         at java.io.File.createTempFile(Unknown Source)
    *question : If I continuously request to open a file that go over system limit, is it possible for JVM to be
    terminated?
    *question : Is there a method that obtains state of System limit in the java library.
    *question : what is the best solution to cope with ?
    Please help me
    =

    struts-config.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
    <struts-config>
      <form-beans>
           <form-bean name="registrationForm" type="ndlinh.struts.lab.RegistrationForm" />
      </form-beans>
      <action-mappings>
           <action path="/register"
                   type="ndlinh.struts.lab.RegistrationAction" // action class
                   name="registrationForm" // form bean name
                   validate="false"
                   scope="request"
                   input="registration.jsp" >
                <forward name="success" path="/jsp/success.jsp"  />
                <forward name="failure" path="/jsp/failure.jsp"  />
           </action>
      </action-mappings>
    </struts-config>HTH

  • Pricing : ABAP to Java conversion help needed

    Hi all.
    I am basically an ABAP developer. My recent assignment needs some java coding.
    It will be very helpful if we anybody helps me in finding the corresponding pricing fields in java.
    The abap code is as follows
    check : xkomv - kgrpe  = '  '.
    check: xkomv - xkbetr ne 0.
    check : komp - kpein ne 0.
    if komp - netwr < 0.
      komp - netpr = 0 - komp - netpr.
    endif.
    xkwert  = (        (  ( komp - netpr * ( 100000 + xkomv - xkbetr))     / 100000)
    komp-mglme / komp-kumza * komp - kumne / 1000 / komp - kpein )
      - komp-netwr.
    Please help in converting this abap code to its corresponding java code.
    Thanks and Regards
    Deepika

    Here is the code I have developed: Please check and let me know if there are any changes
    import java.math.BigDecimal;
    import com.sap.spe.pricing.customizing.PricingCustomizingConstants;
    import com.sap.spe.pricing.transactiondata.PricingTransactiondataConstants;
    import com.sap.spe.pricing.transactiondata.userexit.IPricingConditionUserExit;
    import com.sap.spe.pricing.transactiondata.userexit.IPricingItemUserExit;
    import com.sap.spe.pricing.transactiondata.userexit.ValueFormulaAdapter;
    public class ZS2S_IPC_ZDCP extends ValueFormulaAdapter {
          public BigDecimal overwriteConditionValue(
                IPricingItemUserExit item,
                IPricingConditionUserExit condition) {
                BigDecimal kompKumza = new BigDecimal(String.valueOf(condition.getFraction().getNumerator()));
                BigDecimal kompKumne = new BigDecimal(String.valueOf(condition.getFraction().getDenominator()));
                boolean xkomvKgrpe = condition.isGroupCondition();
                BigDecimal kompKpein = condition.getPricingUnit().getValue();    
                BigDecimal kompNetwr  = item.getNetValue().getValue();
                BigDecimal kompNetpr  = item.getNetPrice().getValue();
                BigDecimal xkomvKbetr = condition.getConditionRate().getValue();
                BigDecimal kompMglme = item.getBaseQuantity().getValue();
                  if ( xkomvKgrpe = true )
                      return PricingTransactiondataConstants.ZERO;
                  if ( kompKumza != PricingTransactiondataConstants.ZERO )
                    return PricingTransactiondataConstants.ZERO;
                if ( kompKumne != PricingTransactiondataConstants.ZERO )
                      return PricingTransactiondataConstants.ZERO;   
                if ( kompKpein != PricingTransactiondataConstants.ZERO )
                        return PricingTransactiondataConstants.ZERO;
                if (kompNetwr.compareTo(PricingTransactiondataConstants.ZERO) < 0 )
                      kompNetpr = (PricingTransactiondataConstants.ZERO).subtract(kompNetwr);
                 BigDecimal y = new BigDecimal("100000");
                BigDecimal a = y.add(xkomvKbetr);
                BigDecimal temp = kompNetpr.multiply(a);
                BigDecimal result1 = temp.divide(y, 2, BigDecimal.ROUND_HALF_UP);
                BigDecimal result2 = result1.multiply(kompMglme)
                                         .divide(kompKumza, 2 BigDecimal.ROUND_HALF_UP).multiply(kompKumne).divide(kompKpein, 2,  BigDecimal.ROUND_HALF_UP);
                BigDecimal Result = result2.subtract(kompNetwr);
              return Result;
    Edited by: Deepika Mallya on Aug 6, 2009 9:08 AM

  • Do week-long java courses help to understand java &  get a job?

    i tried searching for this topic before posting, but "courses" "classes" & "instruction" come up with a lot that has nothing to do with the topic at hand. :)
    like many others, i'm teaching myself out of a book (Deitel). so far i've been able to understand the material and create programs based on the exercises. however, i'm now into the meat of OOP with superclass, subclasses, how they interact and the like and i'm having a rough go of it. i can diagram and understand the abstract concept, but when i'm faced with an actual program example i have a difficult time following the interactions between classes.
    i'm considering taking one of those 5 day classes, but am wary of how much they will actually be able to cover in detail (not to mention the $$). has anyone here taken one of those classes and found them to be of great benefit to learning the OOP portion of Java? did it give you enough understanding to obtain an entry-level job?
    btw, i'm doing a pro bono project for a small company to get some real world experience. (i've heard that suggestion many times in regards to obtaining one's "experience" w/o a job)
    thank you all very much for your help.

    I took a week long course to learn Java. It worked I did learn the basics of Java but I did already know how to program in C and VB at the time. I found the AWT section of the class to be very valuable,cosidering I mostly write GUI. And the concepts of AWT mostly all apply to swing so that didn't set me back at all. Depending on the school it may help you to understand OOP. But be careful because most schools progress the class at the skill level of the majorty. So if you have 15 people in the class and 9 of them know nothing about programing your probably going to spend the week learning what a variable and a while loop do, you all pay the same tuition and they would rather 6 of you leave then 9 of you leave. If you have some prior programming knowledge I would recomend finding a class that caters to that.

  • Simple java question, help please

    please help
    -i am just starting out in java and im havin an early problem. Im trying to run a small java script from a commant prompt but im getting the following error after i enter this command at my prompt
    c:\javatest>javac HelloARP.java
    javac is not as an internal or external command, operable program or batch file.
    when i enter
    c:\java -version
    i get the following message: registry key software\javasoft\java runtime enviornment\current version has value of 1.1 but 1.4 is requiured
    error: could not find java.dll
    error: could not find java 2 runtime enviornment
    -im sure this is a simple error on my part. all im trying to do is run my first lil program that i saved in notepad, its only 5 lines long. here is the lil test program im trying to execute
    class HelloARP {
    public static void main (String[] arguments) {
    System.out.println("What's good ARP?");
    - all responses and help are welcomed. Thank you ahead of time for anyone that can help me get started.

    Hi
    First of all uninstall your current JDK installation, if you can get to the registry delete the registry entries for the old version of java which was there on your machine.
    Now do a fresh install of your j2sdk1.4.1, make sure that you will install the JRE with the J2SDK1.4.1.
    Once you are done, set your classpath in autoexec.bat if you are using Windows 95/98
    or set your environment variables if you are using Win NT/2000/XP.
    If using solaris or other unix flavors see the included installation instructions provided.
    Let me if you face the same problem.
    Thanks
    Swaraj

  • Java Progrramming HELP, Needed Urgently, T hanks

    hey guys,
    I have this lab I need to be done tomorrow, its been weeks lol of thinking and figuring things out can someone make it work ? Pleaseeeee !
    I feel like going out and yelling for help lol I have been trying to figure this out for weeks now.
    I am pasting my Lab and My Codes I did so far, And Please I really need this done today at any rate, all help would be kindly appreciated.
    A Java program is required that will produce a number of reports based on the data from the Product file. This file contains the product name, cost, quantity and UPC. The file name must be input. Valid data from the file will be loaded into an array.
    A menu will provide the following options: (Note there are changes from previous assignment.)
    1     Display of all valid product information including extended price and GST including totals sorted by name.
    2     Display of all invalid records sorted by name.
    3     Search and display a certain product by name.
    4     Sort by UPC and use a binary search and display a certain product by UPC. (valid records)
    9 Exit.
    Processing requirements:
    Input the data from a file and load the records into an object array. Use this object array to produce the above reports.
    Code a class definition exactly as given in the following UML.
    (For specific students: you may code the UPC as an integer but if not numeric throw an exception that is handled in main. Document your choice in your submission).
    Product
    ? Name : String
    ? UPC : String
    ? Cost : Real
    ? Quantity : Integer
    + Product (Name : String, UPC : String, Cost : Real, Quantity : Integer)
    + Calculate Extended Cost() : Real
    + Calculate GST(): Real
    Input Record:
    Product name: String
    UPC: String
    Cost: real
    Quantity: integer
    Output Reports
    1. Display of all product information including extended cost and GST including totals of these 3 fields.
    Following is a sample of the output required:
    ************************ Product Cost REPORT ****************************
    Product                    Cost Quantity Extended Cost     GST     Total Cost
    Diamond Necklace 12345678901x 54,321.99 188 10,212,534.12 510,626.71 10,723,160.83
    Tissues 98989898989x 1.99 2 3.98      0.20     4.18
    TOTALS                         10,212,538.10 510,626.91 10,723,165.01
    2. Display of all invalid records and the count.
    Following is a sample of the output required:
    Invalid UPC Records = 1
    Count Record
    1          Tiara Diamond, 12345678901x, 36020.00, 2
    3. Search and display a certain product by name. Display appropriate message if not found.
    Following is a sample of the output required:
    Enter product name: CrownJewels
    CrownJewels 99999999991x     100,000.00 1 100,000.00 5,000.00 $105,000.00
    6. Display the product information sorted by name
    Following is a sample of the output required:
    ************************ Product Cost REPORT ****************************
    Product                    Cost Quantity Extended Cost     GST     Total Cost
    CrownJewels 99999999991x 100,000.00 1 100,000.00 5,000.00 $105,000.00
    Diamond Necklace 12345678901x 54,321.99 188 10,212,534.12 510,626.71 $10,723,160.83
    Pearls      88888888881x 10,000.00 1 10,000.00 500.00 $10,500.00
    RubyRing      77777777771x 10,000.00 1 10,000.00 500.00 $10,500.00
    Tissues      98989898989x 1.99 2 3.98 0.20     $4.18
    TOTALS          (complete these values)           xxx           xxx      xxx
    Java coding requirements for this assignment
    Main methods required
    1.     Load array with all records. Display exception messages only for records that have invalid data in any of the fields. Return array of valid records and logical size.
    2.     Validate the UPC. Display each report when requested from the menu.
    3.     Justify the data in the columns. Right justify numeric fields; left justify the alpha fields.
    4.     A method for each report required in the menu.
    Class methods
    5.     Use the object method for the extended cost.
    6.     Use the object method for the GST.
    You may use additional methods in the main program but do not add any methods in the class definition.
    Use DecimalFormat for rounding.
    Create an array to hold the objects. Assume that we only need to process a file of a maximum of 500 records but the file may be larger than 500 records.
    A Universal Product Code consists of 12 digits. The first digit (from the left) is the UPC type. The next five digits are the Manufacturer code. The next five digits are the product code which is assigned by the manufacturer. The final digit is the check digit. A person can determine the check digit of a Universal Product Code by doing the following:
    Step 1: Sum all of the digits in the odd positions together.
    0+4+0+1+5+9 = 19
    Step 2: Multiply the sum from Step 1 by 3.
    3 * 19 = 57
    Step 3: Sum all of the digits in the even positions together.
    6+2+0+1+8 = 17
    Step 4: Sum together the results from Step 2 and Step 3.
    17 + 57 = 74
    Step 5: Subtract the sum from the next highest multiple of 10.
    80 - 74 = 6 [check digit]
    TEST DATA:
    Step 1: Create 5 or MORE additional records that will test all conditions. Include these in your documentation. Identify what field is tested in your test data. (Example: error in each field of the record, rounding up, rounding down, valid UPC, invalid UPC, formatting of report, file too large
    Step 2: Use the file attached.
    GODDDDDDDDDDDDDD lol pasting it made me go crazy,
    these are my codes so far, HOwever the problem is ONLY DISPLAY MENU SHOWS, nothing else even though i have enough codes that it can show something,
    My codes are as follows:
    I am working on Eclipse.
    import java.util.Arrays;
    import java.util.Scanner;
    import java.io.*;
    import java.util.*;
    import java.io.IOException;
    * Name : Sana Ghani
    * Date : July 10
    public class lab56
         public static Scanner file;
         public static Scanner parse;
         public static Scanner input = new Scanner(System.in);
         public static Scanner searchInput = new Scanner(System.in);
         public static void main(String[] args) throws Exception
              Product1[] validProduct = new Product1[500];
              int logicalSize = 0;
              int menuChoice=0;
              String FileName = getFileName();
              displayMenu();
              switch(menuChoice)
              case 1:
                   displayAllValidRecords(validProduct, logicalSize);
                   try
                   // Open an output stream
                   OutputStream fout = new FileOutputStream ("myfile.txt");
                   // Print a line of text
                   new PrintStream(fout).println ("hello world!");
                   // Close our output stream
                   fout.close();          
                   // Catches any error conditions
                   catch (IOException e)
                        System.err.println ("Unable to write to file");
                        System.exit(-1);
                   break;
              case 2:
                   break;
              case 3:
                   binarySearchByName( validProduct,logicalSize);
                   break;
              case 4:
                   break;
              case 5:
                   break;
              menuChoice = displayMenu();
         public static void display(Product1[]validProduct, int logicalSize)throws Exception
              String Product, UPC;
              double Cost;
              int Quantity;
              for(int index =0; index<logicalSize; index++)
                   Product = validProduct[index].GetName();
                   UPC = validProduct[index].GetUPC();
                   Cost=validProduct[index].GetCost();
                   Quantity=validProduct[index].GetQuantity();
                   System.out.println(Product+"\t\t"+UPC+"\t\t"+Cost+"\t\t"+Quantity);
         public static String getFileName()
              String fileName;
              Scanner input = new Scanner(System.in);
              System.out.print("Please enter a file name: ");
              fileName = input.next();
              return fileName;
         public static int displayMenu()
              int menuChoice;
              boolean validFlag = false;
              do
                   System.out.println("\n\n*************************************");
                   System.out.println(" Product Display Menu ");
                   System.out.println("*************************************");
                   System.out.println("(1)Display All Records");
                   System.out.println("(2)Display All Invalid Records");
                   System.out.println("(3)Search by Product Name");
                   System.out.println("(4)Sort by Product Name");
                   System.out.println("(5)Exit");
                   System.out.println("*************************************");
                   System.out.print("Enter your choice(1-5): ");
                   menuChoice = input.nextInt();
                   if ((menuChoice >= 1) && (menuChoice <= 5))
                        validFlag = true;
                   if (!validFlag)
                        System.out.println("You have chosen " + menuChoice + ", " + menuChoice +
                        " is not valid. Please try again");
              }while(!validFlag);
              return menuChoice;
         public static String loadArray(Product1 [] ValidProduct, String fileName)throws Exception
              int logicalSize=0;//will always have to declare
              String record;//will always have to declare
              String Product, UPC;//variable names from
              double Quantity;
              double Cost;
              Scanner file = new Scanner(new File(fileName));//open
              record = file.nextLine();//read a line
              record = file.nextLine();//read a line
              for(int index = 0; index < ValidProduct.length && file.hasNext(); index++)//check to see if the file has data
                   record = file.nextLine();
                   parse = new Scanner(record).useDelimiter(",");
                   String Name = parse.next();
                   UPC = parse.next();
                   Cost = parse.nextDouble();
                   Quantity=parse.nextDouble();
                   ValidProduct[index] = new Product1 ( Name, UPC, Cost, (int) Quantity);
    //               create the object-- call the constructor and pass info
                   logicalSize++;
              return logicalSize+".txt";
         public static double roundDouble(double value, int position)
              java.math.BigDecimal bd = new java.math.BigDecimal(value);
              bd = bd.setScale(position,java.math.BigDecimal.ROUND_UP);
              return bd.doubleValue();
         * This method will print report about valid records
         public static void displayAllRecords( Product1[]valid, int ValidProduct,
                   Product1[] invalid, int InvalidProduct)
    //          Print valid records
              displayAllValidRecords(valid, ValidProduct);
    //          Print invalid UPC records
              displayAllValidRecords(invalid, InvalidProduct);
         public static void displayOneRecord(Product1[]valid, int index)
              double extendedCost, GST, SumofGST = 0, // Total Extended Cost
              totalCost, SumOfTotalCost = 0; // Total Extended Cost + GST
    //          Print title
              System.out.println(leftJustify("Product", 50) +
                        leftJustify("UPC", 15) +
                        rightJustify("Cost", 10) +
                        rightJustify("Quantity", 5) +
                        rightJustify("Extended Cost", 15) +
                        rightJustify("GST", 5) +
                        rightJustify("Total Cost", 13));
              extendedCost = valid[index].CalculateExtendedCost();
              extendedCost = roundDouble(extendedCost, 2);
              GST = valid[index].CalculateGST();
              GST = roundDouble(GST, 2);
              totalCost = extendedCost + GST;
              totalCost = roundDouble(totalCost, 2);
    //          justify method ensures all values are of the same size
              System.out.println(//leftJustify(i+"",3) + ": " +
                        leftJustify(valid[index].GetName(), 50) +
                        leftJustify(valid[index].GetUPC(), 15) +
                        rightJustify(valid[index].GetCost()+"", 10) +
                        rightJustify(valid[index].GetQuantity()+"", 5) +
                        rightJustify(extendedCost+"", 10) +
                        rightJustify(GST+"", 10) +
                        rightJustify(totalCost+"", 10));
         * This method will print report about valid records
         public static void displayAllValidRecords( Product1[]valid, int validCounter)
              double extendedCost, sumOfExtendedCost = 0, // Total Extended Cost
              GST, sumOfGST = 0, // Total GST
              totalCost, sumOfTotalCost = 0; // Total Extended Cost + GST
              System.out.println("************************ XYZ Product " +
                        "Cost REPORT ****************************" +
    //          Print title
              System.out.println(leftJustify("Product", 50) +
                        leftJustify("UPC", 15) +
                        rightJustify("Cost", 10) +
                        rightJustify("Qty", 5) +
                        rightJustify("Extended Cost", 15) +
                        rightJustify("GST", 5) +
                        rightJustify("Total Cost", 13));
    //          Print Records
              for(int i=0; i<validCounter; i++)
                   extendedCost = valid.CalculateExtendedCost();
                   extendedCost = roundDouble(extendedCost, 2);
                   GST = valid[i].CalculateGST();
                   GST = roundDouble(GST, 2);
                   totalCost = extendedCost + GST;
                   totalCost = roundDouble(totalCost, 2);
    //               justify method ensures all values are of the same size
                   System.out.println(//leftJustify(i+"",3) + ": " +
                             leftJustify(valid[i].GetName(), 50) +
                             leftJustify(valid[i].GetUPC(), 15) +
                             rightJustify(valid[i].getClass()+"", 10) +
                             rightJustify(valid[i].GetQuantity()+"", 5) +
                             rightJustify(extendedCost+"", 10) +
                             rightJustify(GST+"", 10) +
                             rightJustify(totalCost+"", 10));
                   sumOfExtendedCost += extendedCost;
                   sumOfGST += GST;
                   sumOfTotalCost += totalCost;
         private static void sortByName(Product1 [] ValidProduct, int logicalSize) throws Exception
              Product1 temp;
              for (int outer = logicalSize-1; outer > 1; outer --)
                   for (int inner = 0; inner < outer; inner ++)
                        if (ValidProduct[inner].GetName().compareToIgnoreCase(ValidProduct[inner+1].GetName())>0)
                             temp = ValidProduct[inner];
                             ValidProduct[inner] = ValidProduct[inner + 1];
                             ValidProduct [+ 1] = temp;
         public static void binarySearchByName(Product1 [] ValidProduct, int logicalSize)
              int high = logicalSize - 1;
              int low = 0;
              int mid = 0;
              int count = 0;
              int compare = 0;
              boolean found = false;
              System.out.print("Enter a product name");
              String product = input.nextLine();
              while (high >= low && !found)
                   count += 1;
                   mid = (high + low) / 2;
                   compare = ValidProduct[mid].GetName().compareToIgnoreCase(product);
                   if (compare == 0)
                        System.out.println("Found: " + ValidProduct[mid].GetName());
                        found = true;
                   else if (compare < 0)
                        low = mid + 1;
                   else
                        high = mid - 1;
              if (!found)
                   System.out.println(product + " not found.");
              System.out.println(count + " steps");
              System.out.println();
         public static String leftJustify(String field, int width)
              StringBuffer buffer = new StringBuffer(field);
              while (buffer.length() < width)
                   buffer.append(' ');
              return buffer.toString();
         public static String rightJustify(String field, int width)
              StringBuffer buffer = new StringBuffer(field);
              while (buffer.length() < width)
                   buffer.append(' ');
              return buffer.toString();
         public static void displayValidRecords(Product1 [] ValidProduct, int logicalSize) throws Exception {
              long longMAX_POSSIBLE_UPC_CODE = 999999999999L;
              // set input stream and get number
              Scanner stdin = new Scanner(System.in);
              System.out.print("Enter a 12-digit UPC number: ");
              long input =stdin.nextLong();
              long number = input;
              // determine whether number is a possible UPC code
              if ((input < 0)|| (input > longMAX_POSSIBLE_UPC_CODE)) {
                   // not a UPC code
                   System.out.println(input +"is an invalid UPC code");
              else {   
                   // might be a UPC code
                   // determine digits
                   int d12 = (int) (number % 10);
                   number /= 10;
                   int d11 = (int) (number % 10);
                   number /= 10;
                   int d10 = (int) (number % 10);
                   number /= 10;
                   int d9 = (int) (number % 10);
                   number /= 10;
                   int d8 = (int) (number % 10);
                   number /= 10;
                   int d7 = (int) (number % 10);
                   number /= 10;
                   int d6 = (int) (number % 10);
                   number /= 10;
                   int d5 = (int) (number % 10);
                   number /= 10;
                   int d4 = (int) (number % 10);
                   number /= 10;
                   int d3 = (int) (number % 10);
                   number /= 10;
                   int d2 = (int) (number % 10);
                   number /= 10;
                   int d1 = (int) (number % 10);
                   number /= 10;
                   // compute sums of first 5 even digits and the odd digits
                   int m = d2 + d4 d6 d8 + d10;
                   int n = d1 + d3 d5 d7 + d9 + d11;
                   // use UPC formula to determine required value for d12
                   int r = 10 - ((m +3*n) % 10);
                   // based on r, can test whether number is a UPC code
                   if (r == d12) {
                        // is a UPCcode
                        System.out.println(input+" is a valid UPC code");
                   else {   
                        // not a UPCcode
                        System.out.println(input+" is not valid UPC code");
    Any help would be great thanks !!
    Take care,

    1) It's your problem that you waited until the last minute before you went for help...not ours. We'll give your problem the same attention as anyone elses...therefore your problem isn't any more urgent than any other problem here.
    2) I don't intend on doing your entire assignment. Nor do I intend on reading all of it. If you need help with a specific requirement, then post the information/code relevant to that requirement. I don't know how to help you when you bury the problem inside a 9 mile long essay.
    3) Post code in tags so it's formatted and readable. (there's a *code* button up above that makes the tags for you).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • About to fail Java..HELP

    Here's the story..I am horrable at Java. I took this class..I am having a lot of trouble and the teacher will not help me.. Here's my assignment..
    Write a program to compute mileage statistics for an automobile. Mr. Magoo has kept track of several tankfuls of gasoline by recording miles driven and gallons used for each tankful. Develop a Java application that will let Mr. Magoo input miles driven and gallons used (both ints) for each tankful and then display the miles per gallon obtained (a double). When Mr. Magoo enters -1 for miles, the program will display the total miles, total gallons, (both ints) and overall miles per gallon (a double, display rounded to 2 decimal places).Use a priming read similar to that found on page 4 of the Chap 4 handout. Continue processing input values until Mr. Magoo enters the sentinel value of -1. Use a message dialog at the start of the program that tells him what the valid input values are and what sentinel value to use to end processing. When Mr. Magoo enters an invalid amount (<= 0) for either value, there should be an error dialog box. Mr. Magoo might possibly enter two (or more) invalid amounts in a row! Make sure the program catches all invalid data.After Mr. Magoo enters the sentinel value, print out the totals. Invalid values are not included in the totals. There should be 1 information message which says "Valid miles and gallons are >0 and on the next line.."Enter -1 for miles to end processing" and then 1 box to enter mmiles, 1 to enter gallons, and an information message to say "MPG this tankful is: " TEST DATA:
         MILES     GALLONS
         155     6
         -300
         375     11
         284     8
         145     -5
         309     10
         -1
    heres my code which is very wrong, not complete and generated many errors:
    import javax.swing.JOptionPane;
    public class Mpg
    public static void main(String args[])
              String getMpg;
              double Mpg, gallons, miles;
              JOptionPane.INFORMATION_MESSAGE (null, "Valid miles and gallons are >0
              "\nEnter -1 for miles to end processing.");
              Mpg = Double.parseDouble(getMpg);
              Mpg = miles / gallons;
              JOptionPane.showInputDialog (null, "Number of miles: " + miles +","Results", JOptionPane.QUESTION_MESSAGE );
              JOptionPane.showInputDialog (null, "Number of gallons: " + gallons +", "Results", JOptionPane.QUESTION_MESSAGE );
              JOptionPane.showInputDialog (null, "MPG this tankful: " + Mpg +", "Results", JOptionPane.INFORMATION_MESSAGE );
              System.exit(0);
    I would be thankful for any help I can recieve. I have no idea how to make this program work. I am banging my head against walls!!!! Thanks Everyone!

    Hi,
    Whilst not agreeing with the tone of some of the messages the principle is correct up to a point.
    Anyway a little help is needed here :)
    Your program could be done in any language as its basically a procedural task. Lets look at that first.
    Your input screen - be it the command line or a JOptionPane must have a "switch" behind it that filters out unwanted input and only calls the mpg formula if the input is correct.
    To make the calculation you need to temporarily store two values "milestravelled" and "gallonsused"
    The input reciever should look for "milestravelled" first and when that has been correctly input ( > 0 ) it will treat the next input as "gallonsused".
    Once the two values are stores it should automatically - or by request - calculate the MPG figure and display it.
    Secondly, your code had some syntax errors I've corrected - there was an extra +" after the miles, gallons and Mpg variables
    JOptionPane.showInputDialog (null, "Number of miles: " + miles ,"Results", JOptionPane.QUESTION_MESSAGE );
    JOptionPane.showInputDialog (null, "Number of gallons: " + gallons , "Results", JOptionPane.QUESTION_MESSAGE );
    JOptionPane.showInputDialog (null, "MPG this tankful: " + Mpg , "Results", JOptionPane.INFORMATION_MESSAGE );
    Your information message declaration is not correct either. I suggest you check your syntax using the JDK documentation or your book.
    I hope that helps a little and will encourage you to work out the rest on your own.
    PS: Why are you using swing? A simple command line application would do fine for this task. Is it a course requirement or are you using a java development program to learn java. If its the second reason I think I can see why you're a bit lost. The IDE programs stick in a load of code that may not be necessary at all. The best way to learn is using the trusty JDK and notepad :)
    Bye

  • I grab a null frame.  Can a Java genious help, please?

    Hello. I am a high school student working on a science fair project. Right now I am using JMF to grab a frame from my ATI TV Wonder USB. The code below accesses the TV Wonder but it seems like I get a null frame because I have put a if statement in the code and it says I have a null image there. Can someone please help me. Thank you in advance
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.text.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.media.*;
    import javax.media.format.*;
    import javax.media.util.*;
    import javax.media.control.*;
    import javax.media.protocol.*;
    import javax.media.control.FormatControl;
    public class Cell extends JApplet implements ActionListener{
         JLabel welcomeLabel;
         JTextArea output;
         JButton close;
         String display = "";
         String exit = "The video capture buffer has been terminated.";
         String problem = "";
         String videoDevice = "vfw:Microsoft WDM Image Capture (Win32):0";
         public static Player player = null;
         public Buffer buf = null;
         public Image img = null;
         public VideoFormat vf = null;
         public BufferToImage btoi = null;
         public MediaLocator ml = null;
         public CaptureDeviceInfo di = null;
         public void init()
              Container c = getContentPane();
              c.setLayout( new FlowLayout() );
              welcomeLabel = new JLabel("Welcome to Adam's Cell Analyzer");
              c.add(welcomeLabel);
              output = new JTextArea(6, 60);
              output.setFont( new Font("Courier", Font.PLAIN, 12) );
              c.add(output);
              close = new JButton("End Analyze Program");
              close.addActionListener(this);
              c.add(close);
              display = "Starting...\n\n";
              output.setText(display);
              di = CaptureDeviceManager.getDevice(videoDevice);
              ml = di.getLocator();
              try {
                   player = Manager.createRealizedPlayer(ml);
                   player.start();
                   Component comp;
              catch (Exception e) {
                   problem += "An Exception has occured.";
                   output.setText(problem);
              FrameGrabbingControl fgc = (FrameGrabbingControl)
                   player.getControl("javax.media.control.FrameGrabbingControl");
              buf = fgc.grabFrame();
              btoi = new BufferToImage((VideoFormat)buf.getFormat());
              img = btoi.createImage(buf);
              display += "The video capture card is currently working properly\n";
              display += "and is sending a video feed to the image buffer.\n\n";
              output.setText(display);
              if(img==null){
                   problem += "The frame is null.";
                   output.setText(problem);
              else
                   imageEnhancement(img);
         public void actionPerformed(ActionEvent e)
              output.setText(exit);
              player.close();
              player.deallocate();
         private void imageEnhancement(Image img)
         //Nothing now     
    }

    I decided to post my program on here because I remember how hard it was to get it to work, and I don't want people to go through the same problems... just don't use it to compete against me in the Intel Science and Engineering Fair and/or the Intel Science Talent Search ;-) then I'll be mad. Other than that, have fun!
    ~Adam Georgas
    import java.awt.*;
    import java.awt.Dimension;
    import java.awt.event.*;
    import java.awt.Image.*;
    import java.awt.image.renderable.*;
    import java.io.*;
    import java.text.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.media.*;
    import javax.media.format.*;
    import javax.media.format.VideoFormat;
    import javax.media.util.*;
    import javax.media.util.BufferToImage;
    import javax.media.control.*;
    import javax.media.protocol.*;
    import javax.media.control.FormatControl;
    public class Cell extends JApplet implements ActionListener{
         JLabel welcomeLabel;
         JTextArea output;
         JButton begin;
         JButton end;
         String display = "";
         String problem = "";
         String exit = "The video capture buffer has been terminated.";
         String videoDevice = "vfw:Microsoft WDM Image Capture (Win32):0";
         public static Player player = null;
         public Buffer buf = null;
         public MediaLocator ml = null;
         public CaptureDeviceInfo di = null;
         public BufferToImage btoi = null;
         public Image frameImage = null;
         public VideoFormat vf = null;
         public PlanarImage src = null;
         private ImageEncoder encoder = null;
    private JPEGEncodeParam encodeParam = null;
         int error = 0;
         public void init()
              Container c = getContentPane();
              c.setLayout( new FlowLayout() );
              welcomeLabel = new JLabel("Welcome to Adam's Cell Analyzer");
              c.add(welcomeLabel);
              output = new JTextArea(6, 60);
              output.setFont( new Font("Courier", Font.PLAIN, 12) );
              c.add(output);
              begin = new JButton("Begin Analyze Program");
              begin.addActionListener(this);
              c.add(begin);
              end = new JButton("End Analyze Program");
              end.addActionListener(this);
              c.add(end);
              di = CaptureDeviceManager.getDevice(videoDevice);
              ml = di.getLocator();
              try {
                   player = Manager.createRealizedPlayer(ml);
                   player.start();
              catch (Exception b) {
                   JOptionPane.showMessageDialog(this, b.toString(),
                        "An Exception has occured", JOptionPane.ERROR_MESSAGE);
              display = "Welcome\n\n";
              output.setText(display);
         public void actionPerformed(ActionEvent e)
              JComponent j = (JComponent) e.getSource();
              if (j == end){
                   player.close();
                   player.deallocate();
                   output.setText(exit);     
              if (j == begin){
                   display += "Starting...\n\n";
                   output.setText(display);
                   Control[] controls = player.getControls();
                   FrameGrabbingControl fgc = (FrameGrabbingControl)
                        player.getControl("javax.media.control.FrameGrabbingControl");
                   if (fgc == null) {
                        error = 1;
                        problem(error);
                   buf = fgc.grabFrame();
                   btoi = new BufferToImage((VideoFormat)buf.getFormat());
                   if (btoi == null){
                        error = 2;
                        problem(error);
                   VideoFormat format = (VideoFormat)buf.getFormat();
                   Dimension size = format.getSize();
                   if(format == null) {
                        error = 3;
                        problem(error);
                   frameImage = btoi.createImage(buf);               
                   if(frameImage == null) {
                        error = 4;
                        problem(error);
                   else{
                        display = "";
                        display = "The video system is working correctly and grabbing frames.\n\n";
                        output.setText(display);     
         public void imageEnhancement()
    //Top Secret :-)
         public void problem(int error)
              switch(error) {
              case 1:
                   JOptionPane.showMessageDialog(this, "The frame grabbing control is null.",
                        "A problem has occured", JOptionPane.ERROR_MESSAGE);
                   break;
              case 2:
                   JOptionPane.showMessageDialog(this, "The buffer to image conversion did not occur properly.",
                        "A problem has occured", JOptionPane.ERROR_MESSAGE);
                   break;
              case 3:
                   JOptionPane.showMessageDialog(this, "The image format queries did not occur properly.",
                        "A problem has occured", JOptionPane.ERROR_MESSAGE);
                   break;
              case 4:
                   JOptionPane.showMessageDialog(this, "The buffer to image did not occur properly.",
                        "A problem has occured", JOptionPane.ERROR_MESSAGE);
                   break;
              case 5:
                   JOptionPane.showMessageDialog(this, "Java AWT Image to JAI Image did not occur properly.",
                        "A problem has occured", JOptionPane.ERROR_MESSAGE);
                   break;
              default:
                   JOptionPane.showMessageDialog(this, "An unknown problem has occured.",
                        "A problem has occured", JOptionPane.ERROR_MESSAGE);
    }

  • How to use padding scheme FIPS81 in java plz help?

    Plz refer the below code using this code I m trying to decrypt XLS file using pass phrase.
    I m using the same pass phrase which was used @ the time of encryption.
    But the problem I m facing is that the file was encrypted in DOT NET_ using padding scheme FIPS81 and there impelmentation of FIPS81 is not available in JAVA so that it gives exception at the time of decryption which is given below
    Exception : javax.crypto.BadPaddingException: Given final block not properly padded
    I urgently need the solution of this problem so somebody plz help me to find the solution of this problem.....Ur reply would be appriciated.....!!
    The File is Encrypted using below mechanism
    ALGORITHM : AES
    MODE : ECB
    PADDING SCHEME : FIPS81
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.UnsupportedEncodingException;
    import java.security.MessageDigest;
    import java.security.NoSuchAlgorithmException;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    public class DecryptTest {
         public static void main(String[] s){
              String passPhrase = "passphrase";
              String encFileName = "encsample.xls";
              String decFileName = "decsample.xls";
              FileInputStream encFileIn = null;
              FileOutputStream decFileOut = null;
              File f = null;
              byte[] message;
              try {
                   f = new File(encFileName);
                   encFileIn = new FileInputStream(f);
                   decFileOut = new FileOutputStream(decFileName);
                   message = new byte[encFileIn.available()]; //Read the encrypted file in from disk
                   encFileIn.read(message);
                   SecretKeySpec spec = new SecretKeySpec(passwordToKey (passPhrase), "AES");
                   //decrypt it
                   Cipher c = Cipher.getInstance("AES/ECB/NoPadding");
                   c.init(Cipher.DECRYPT_MODE, spec);
                   System.out.println("Block Size is >-->" + c.getBlockSize());
                   String decryptedString = new String(c.doFinal(message));
                   System.out.println("Decrypted message: " + decryptedString);
                   //To write into another files
                   decFileOut.write(decryptedString.getBytes());
              }catch (Exception e) {
                   System.out.println(e);
              }finally {
                   try {
                        encFileIn.close();
                        decFileOut.close();     
                   } catch (IOException ioe) {
         }Is there any mechanism is available for FIPS81 or Is there any third party Provider available for it plz reply........????????

    I suggest you look in google http://www.google.co.uk/search?q=SWF+java

  • Java mapping help please

    Hi all,
    I need help with java code please.
    My source is a csv file and target is multiple idocs.
    Source file structure is as follows:
    Header (field 1, field 2, ........ field 10)
    Item 1a (field 1, field 2, field 3, .........    field 180)
    Item 1b (field 1, field 2, field 3, .........    field 180)
    Item 2a (field 1, field 2, field 3, .........    field 180)
    Item 2b (field 1, field 2, field 3, .........    field 180)
    Item na (field 1, field 2, field 3, .........    field 180)
    Item nb (field 1, field 2, field 3, .........    field 180)
    First line is header. Second is VAT line. Third is Price line for that VAT. Now VAT and Price lines repeat. There need not be VAT line for non-European countries. So a VAT line may or may not preceed a Price line.
    For example: the lines can be like:
    Header
    VAT1
    Price1
    VAT2
    Price2
    Price3
    1) Now, it should produce 3 idocs like:
    Header, VAT1, Price1
    Header, VAT2, Price2
    Header, Price3
    2) One idoc should be created per a pair of VAT and Price lines and they will be identified by a co-relation of a particular field. So first I have to sort all the lines based on this field value. Then I have to read the lines in pairs. If no Vat line, I should just read the Price item and produce an idoc.
    Can you please help me with the java code for this?
    Many thanks in advance.
    Ramesh.

    Many thanks Ram.
    The reason for thinking to go for java mapping is that there is no keyfield for price line. The source file is a pipe delimited csv file. There is a keyfield for VAT line. The same field will be empty for the Price line. I am trying to ask them to at least provide a space for that field between the pipes for price line so that I can use in FCC. It looks like they can't modify the source file.
    Any inputs please?
    Regards.
    Ramesh.

Maybe you are looking for