problema con java.oi.FileNotFoundException

jhosua
17 de Marzo del 2004
estoy trabajando con java3d y el problema que tengo es el abrir un archivo de propiedades que esta ligado a otro , mando parte del archivo del que no encuentra y donde se supone que lo carga y tambien no carga la imagen ese es otro problema, les mando los 3 codigos eseperando su ayuda gracias

jhosua
imagen
public class MechLight
{

public static final double scale = 1.0;

public static BranchGroup createPrototype ()
{
BranchGroup protoRoot = new BranchGroup();
protoRoot.setCapability( protoRoot.ALLOW_DETACH );
TransformGroup mechLight = new TransformGroup();
mechLight.setCollidable( false );
mechLight.setCapability( mechLight.ALLOW_TRANSFORM_READ );
mechLight.setCapability( mechLight.ALLOW_TRANSFORM_WRITE );
protoRoot.addChild( mechLight );
TransformGroup model = new TransformGroup();
Transform3D modelTransform = new Transform3D();
modelTransform.rotX( Math.toRadians( -90.0 ) );
modelTransform.setScale( scale );
model.setTransform( modelTransform );
mechLight.addChild( model );
Appearance modelApp = new Appearance();
modelApp.setCapability( modelApp.ALLOW_MATERIAL_READ );
modelApp.setCapability( modelApp.ALLOW_MATERIAL_WRITE );
Material modelMaterial = new Material
(
new Color3f( 0.2f, 0.2f, 0.2f ), // Ambient Colour
new Color3f( 0.0f, 0.0f, 0.0f ), // Emissive Colour
new Color3f( 0.3f, 0.3f, 0.3f ), // Diffuse Colour
new Color3f( 0.75f, 0.75f, 0.75f ), // Specular Colour
64.0f // Shininess
);
modelMaterial.setCapability( Material.ALLOW_COMPONENT_READ );
modelMaterial.setCapability( Material.ALLOW_COMPONENT_WRITE );
modelApp.setMaterial( modelMaterial );
// The base cylinder for the light.
Cylinder lightBase = new Cylinder( 0.015f, 0.15f, Cylinder.GENERATE_NORMALS|Cylinder.BODY|Cylinder.ENABLE_APPEARANCE_MODIFY, modelApp );
model.addChild( lightBase );
// The middle piece for the wide end
TransformGroup endBulge = new TransformGroup();
Transform3D EBTransform = new Transform3D();
EBTransform.setScale( new Vector3d( 0.02f, 0.03f, 0.02f ) );
EBTransform.setTranslation( new Vector3d( 0.0, 0.075, 0.0 ) );
endBulge.setTransform( EBTransform );
model.addChild( endBulge );
Sphere EBObject = new Sphere ( 1.0f, Sphere.GENERATE_NORMALS|Sphere.ENABLE_APPEARANCE_MODIFY, modelApp );
endBulge.addChild( EBObject );
// The main piece for the wide end
TransformGroup lightKnob = new TransformGroup();
Transform3D LKTransform = new Transform3D();
LKTransform.setTranslation( new Vector3d( 0.0, 0.09, 0.0 ) );
lightKnob.setTransform( LKTransform );
model.addChild( lightKnob );
Cylinder LKObject = new Cylinder( 0.02f, 0.03f, Cylinder.GENERATE_NORMALS|Cylinder.BODY|Cylinder.ENABLE_APPEARANCE_MODIFY, modelApp );
lightKnob.addChild( LKObject );
// The ring that adjusts the spotlight sharpness
TransformGroup lightAdjustRing = new TransformGroup();
lightAdjustRing.setCollidable( true );
lightAdjustRing.setCapability( TransformGroup.ALLOW_TRANSFORM_READ );
lightAdjustRing.setCapability( TransformGroup.ALLOW_TRANSFORM_WRITE );
Transform3D LARTransform = new Transform3D();
LARTransform.setTranslation( new Vector3d( 0.0, 0.0925, 0.0 ) );
lightAdjustRing.setTransform( LARTransform );
model.addChild( lightAdjustRing );
Cylinder LARObject = new Cylinder( 0.0225f, 0.0125f, Cylinder.GENERATE_NORMALS|Cylinder.ENABLE_APPEARANCE_MODIFY, modelApp );
lightAdjustRing.addChild( LARObject );
// The light itself
TransformGroup theLight = new TransformGroup();
Transform3D TLTransform = new Transform3D();
LightBulbComponent LBC = new LightBulbComponent( new Vector3d( 0.02, 0.002, 0.02 ) );
TLTransform.setTranslation( new Vector3d( 0.0, 0.105, 0.0 ) );
theLight.setTransform( TLTransform );
model.addChild( theLight );
theLight.addChild( LBC );
Bounds lightBounds = new BoundingSphere( new Point3d( 0.0, 0.0, 0.0 ), 100.0 );
LBC.setLightBounds( lightBounds );
// Battery cap at the end
TransformGroup batteryCap = new TransformGroup();
Transform3D NCTransform = new Transform3D();
NCTransform.setTranslation( new Vector3d( 0.0, -0.085, 0.0 ) );
batteryCap.setTransform( NCTransform );
model.addChild( batteryCap );

Cylinder NCObject = new Cylinder( 0.0175f, 0.02f, Cylinder.GENERATE_NORMALS|Cylinder.ENABLE_APPEARANCE_MODIFY, modelApp );
batteryCap.addChild( NCObject );
// The button
TransformGroup button = new TransformGroup();
button.setCollidable( true );
button.setCapability( button.ALLOW_TRANSFORM_READ );
button.setCapability( button.ALLOW_TRANSFORM_WRITE );
Transform3D buttonTransform = new Transform3D();
buttonTransform.setTranslation( new Vector3d( 0.0, 0.02, 0.0125 ) );
button.setTransform( buttonTransform );
Box buttonObject = new Box( 0.005f, 0.01f, 0.005f, Box.GENERATE_NORMALS|Box.ENABLE_APPEARANCE_MODIFY, modelApp );
button.addChild( buttonObject );
ButtonBehavior buttonBeh = new ButtonBehavior( button, buttonObject, new Vector3d( 0.0, 0.0, -0.0025 ), LBC );
buttonBeh.setSchedulingBounds( new BoundingBox( new Point3d( -0.01, -0.01, 0.0 ),
new Point3d( 0.01, 0.03, 0.02 )
)
);
button.addChild( buttonBeh );
model.addChild( button );
// The helper nodes used to rotate the model with the VirtualHand
TransformGroup backSideClockwiseRotateKludge = new TransformGroup();
backSideClockwiseRotateKludge.setCollidable( true );
Transform3D BSCRKTransform = new Transform3D();
BSCRKTransform.setScale( new Vector3d( 0.0025, 0.05, 0.0025 ) );
BSCRKTransform.setTranslation( new Vector3d( 0.0075, -0.025, 0.0 ) );
backSideClockwiseRotateKludge.setTransform( BSCRKTransform );
model.addChild( backSideClockwiseRotateKludge );
Box BSCRKObject = new Box( );
backSideClockwiseRotateKludge.addChild( BSCRKObject );
RotateCollisionDetector clockwise =
new RotateCollisionDetector( mechLight, new Vector3d( 0, 1.0, 0 ), Math.toRadians( -10 ), backSideClockwiseRotateKludge );
clockwise.setSchedulingBounds( new BoundingBox( new Point3d( 0.01, -0.075, -0.02 ),
new Point3d( 0.02, -0.01, 0.01 )
)
);
model.addChild( clockwise );
TransformGroup backSideCounterClockwiseRotateKludge = new TransformGroup();
backSideCounterClockwiseRotateKludge.setCollidable( true );
Transform3D BSCCRKTransform = new Transform3D();
BSCCRKTransform.setScale( new Vector3d( 0.0025, 0.05, 0.0025 ) );
BSCCRKTransform.setTranslation( new Vector3d( -0.0075, -0.025, 0.0 ) );
backSideCounterClockwiseRotateKludge.setTransform( BSCCRKTransform );
model.addChild( backSideCounterClockwiseRotateKludge );
Box BSCCRKObject = new Box( );
backSideCounterClockwiseRotateKludge.addChild( BSCCRKObject );
RotateCollisionDetector counterClockwise =
new RotateCollisionDetector( mechLight, new Vector3d( 0, 1.0, 0 ), Math.toRadians( 10 ), backSideCounterClockwiseRotateKludge );
counterClockwise.setSchedulingBounds( new BoundingBox( new Point3d( -0.02, -0.075, -0.02 ),
new Point3d( -0.01, -0.01, 0.01 )
)
);
model.addChild( counterClockwise );


//A Textured Box to show off the light
TransformGroup textureBox = new TransformGroup();
Transform3D TBTransform = new Transform3D();
TBTransform.setTranslation( new Vector3d( 0.0, 0.0, -1.1*scale ) );
textureBox.setTransform( TBTransform );
protoRoot.addChild( textureBox );
Appearance textureApp = new Appearance();
textureApp.setCapability( Appearance.ALLOW_MATERIAL_READ );
textureApp.setCapability( Appearance.ALLOW_MATERIAL_WRITE );
Material TAMaterial = new Material
(
new Color3f( 0.0f, 0.0f, 0.0f ), // Ambient Colour
new Color3f( 0.0f, 0.0f, 0.0f ), // Emissive Colour
new Color3f( 0.0f, 0.0f, 0.0f ), // Diffuse Colour
new Color3f( 1.0f, 1.0f, 1.0f ), // Specular Colour
32.0f // Shininess
);
JPanel dummy = new JPanel();
Texture tex = new TextureLoader( "Image.jpg", dummy ).getTexture();
TAMaterial.setCapability( Material.ALLOW_COMPONENT_READ );
TAMaterial.setCapability( Material.ALLOW_COMPONENT_WRITE );
textureApp.setMaterial( TAMaterial );
textureApp.setTexture( tex );
Box textureBoxObject = new Box( 0.3f, 0.3f, 0.01f, Box.GENERATE_TEXTURE_COORDS|Box.GENERATE_NORMALS|Box.ENABLE_APPEARANCE_MODIFY, textureApp );
textureBox.addChild( textureBoxObject );
dummy = null;

//Now that it's all finished, let's return the whole bunch!
//protoRoot.compile();
return protoRoot;

}

}

carga el archivo que no lo encuentra

public class FastrakDriver
{

public static final int X = 0;
public static final int Y = 1;
public static final int Z = 2;
public static final int RECEIVER_1 = 0;
public static final int RECEIVER_2 = 1;
public static final int RECEIVER_3 = 2;
public static final int RECEIVER_4 = 3;


public static final String propertiesFileName = "FastrakDriver.properties";
public static final String deviceNameKey = "DeviceName";
public static final String receiversKey = "Receivers";
public static final String baudRateKey = "BaudRate";
public static final String parityKey = "Parity";
public static final String timeOutKey = "TimeOut";

private static final String toBinaryCommand = "f";
private static final String toASCIICommand = "F";
private static final String toNonContinuousCommand = "c";
private static final String toContinuousCommand = "C";
private static final String getRecordCommand = "P";
private static final String useCentimetresCommand = "u";
private static final String useInchesCommand = "U";

private float [][] receiverRotations = new float[4][3];
private float [][] receiverLocations = new float[4][3];
private String deviceName;
private int receivers = 1;
private int baudRate;
private int dataBits;
private int stopBits;
private int parity;
private int timeOut;

private SerialPort serialPort;
private InputStream pIn;
private OutputStream pOut;
private boolean debug = true;

public FastrakDriver()
{
}

public void initialize() throws Exception
{
debug( "Initializing..." );

// Read settings from properties file
InputStream fIn;
Properties settings = new Properties();
File propertiesFile = new File( propertiesFileName );
fIn = new FileInputStream( propertiesFile );
settings.load( fIn );
fIn.close();
deviceName = settings.getProperty( deviceNameKey );
receivers = Integer.parseInt( settings.getProperty( receiversKey ) );
debug( "Receivers: " + receivers );
baudRate = Integer.parseInt( settings.getProperty( baudRateKey ) );
dataBits = SerialPort.DATABITS_8;
stopBits = SerialPort.STOPBITS_1;
String sParity = settings.getProperty( parityKey );
if( sParity.equalsIgnoreCase( "even" ) )
parity = SerialPort.PARITY_EVEN;
else if( sParity.equalsIgnoreCase( "odd" ) )
parity = SerialPort.PARITY_ODD;
else if( sParity.equalsIgnoreCase( "mark" ) )
parity = SerialPort.PARITY_MARK;
else if( sParity.equalsIgnoreCase( "space" ) )
parity = SerialPort.PARITY_SPACE;
else if( sParity.equalsIgnoreCase( "none" ) )
parity = SerialPort.PARITY_NONE;
else
throw new IllegalArgumentException();
timeOut = Integer.parseInt( settings.getProperty( timeOutKey ) );

// Open the serial port
CommPortIdentifier portID = CommPortIdentifier.getPortIdentifier( deviceName );
serialPort = (SerialPort)portID.open( "FastrakDriver", timeOut );
serialPort.setSerialPortParams( baudRate, dataBits, stopBits, parity );
serialPort.setFlowControlMode( SerialPort.FLOWCONTROL_NONE );
serialPort.enableReceiveThreshold( 1 );
serialPort.enableReceiveTimeout( timeOut );
pIn = serialPort.getInputStream();
pOut = serialPort.getOutputStream();

// Initialize Fastrak
// for( int i = 1; i <= receivers; i++ )
{
String setReceiverParametersCommand = "O" + 1 + ",2,0,4,1r";
write( setReceiverParametersCommand );
}
write( toBinaryCommand );
write( toNonContinuousCommand );
write( useCentimetresCommand );
for( int i = 0; i < 4; i++ )
{
reset( receiverRotations[i] );
reset( receiverLocations[i] );
}

debug( "Initialized" );

}

public float[] getLocation( int forReceiver, boolean forceUpdate ) throws Exception
{
if( forceUpdate )
{
readData();
}
return getLocation( forReceiver );
}

public float[] getLocation( int forReceiver )
{
float values[] = new float[3];
for( int i=0; i<3; i++ )
{
values[i]=receiverLocations[ forReceiver ][ i ];
}
return values;
}

public float[] getRotation( int forReceiver, boolean forceUpdate ) throws Exception
{
if( forceUpdate )
{
readData();
}
return getRotation( forReceiver );
}

public float[] getRotation( int forReceiver )
{
float values[] = new float[3];
for( int i=0; i<3; i++ )
{
values[i]=receiverRotations[ forReceiver ][i];
}
return values;
}

public void readData() throws Exception
{
float value;

write( getRecordCommand );
for( int n=0; n < receivers; n++ )
{
try
{
Thread.sleep( 10 );
}
catch( InterruptedException e )
{}
int [] data = new int[30];

for( int i=0; i < 30; i++ )
{
data[i] = pIn.read();
//System.out.print( data[i] + " " );
}
//System.out.println();
int a=0,b=0,c=0,d=0,bits=0;
for( int i=0; i<3; i++ )
{
a = data[3+4*i];
b = data[4+4*i];
c = data[5+4*i];
d = data[6+4*i];
bits = ( ( d << 24 ) | ( c << 16 ) | ( b << 8 ) | a );
value = Float.intBitsToFloat( bits );
//System.out.println( value );
receiverLocations[n][i] = value;
}
for (int i=0; i<3; i++)
{
a = data[16+4*i];
b = data[17+4*i];
c = data[18+4*i];
d = data[19+4*i];
bits = ( ( d << 24 ) | ( c << 16 ) | ( b << 8 ) | a );
value = Float.intBitsToFloat( bits );
receiverRotations[n][i] = value;
}
}
}

public int getActiveReceivers()
{
return receivers;
}

private void write( String aString ) throws Exception
{
pOut.write( aString.getBytes(), 0, aString.length() );
pOut.flush();
}

private void reset( float[] values )
{
for( int i = 0; i < values.length; i++ )
{
values[i] = 0.0f;
}
}

private void debug( String debugString )
{
if( debug )
{
System.out.println( new Date().toString() + " FastrakDriver: " + debugString );
}
}

public void close() throws Exception
{
pIn.close();
pOut.close();
serialPort.close();
}
}

estos son lo errores que me marcan

Loading class: MechLight
Error loading Image Image.jpg
Glove opened
Fastrak opened
java.io.FileNotFoundException: FastrakDriver.properties (El sistema no puede hallar el archivo especificado)
Error initializing Fastrak, exiting...
Wed Mar 17 11:18:25 GMT-06:00 2004 FastrakDriver: Initializing...

hogala puedan ayudarme

franmoreno
17 de Marzo del 2004
no encuentra el archivo porque no le das el path para llegar hasta el, por ejemplo c:/dir1/dir2/file.ext, no olvides usa el slah a la derecha -> "/" y no el de windows ""