Typo in document System.getProperty
fileconn.dir.MemoryCard.Video must bes fileconn.dir.memorycard.video instead. The former will throw an exception.
Thanks for the find! I will get this update soon.
See you soon,.
Tags: BlackBerry Developers
Similar Questions
-
Hello
I hope someone can help with this query.
I use the code that is very similar to the sample application camerademo to take a photo using the camera. It works properly on devices running OS5. However, on devices running OS6 photo is just an image of white/black.
I think I followed the problem until the encoding string passed to getSnapshot(). When I switch which must be a valid encoding string (based on the output of System.getProperty ("video.snapshot.encodings")) the captured image is a black screen. However, when I pass null to getSnapshot() it works correctly. I want to avoid using null as the captured image is much more that I need and for reasons of effectiveness, I would like to avoid having to reduce its size after the capture of the photo.
I tested this on the 9780 Simulator. The corresponding code is included below for reference.
Thanks in advance!
/* * CameraDemo.java * * Copyright © 1998-2008 Research In Motion Ltd. * * Note: For the sake of simplicity, this sample application may not leverage * resource bundles and resource strings. However, it is STRONGLY recommended * that application developers make use of the localization features available * within the BlackBerry development platform to ensure a seamless application * experience across a variety of languages and geographies. For more information * on localizing your application, please refer to the BlackBerry Java Development * Environment Development Guide associated with this release. */ package com.rim.samples.device.camerademo; import java.util.Vector; import javax.microedition.amms.control.camera.CameraControl; import javax.microedition.media.Manager; import javax.microedition.media.Player; import javax.microedition.media.control.VideoControl; import net.rim.device.api.system.Characters; import net.rim.device.api.ui.Field; import net.rim.device.api.ui.Keypad; import net.rim.device.api.ui.UiApplication; import net.rim.device.api.ui.component.Dialog; import net.rim.device.api.ui.component.RichTextField; import net.rim.device.api.ui.container.MainScreen; import net.rim.device.api.util.StringUtilities; /** * A sample application used to demonstrate the VideoControl.getSnapshot() * method. Creates a custom camera which can take snapshots from the * Blackberry's camera. */ final class CameraDemo extends UiApplication { /** Entry point for this application. */ public static void main(String[] args) { CameraDemo demo = new CameraDemo(); demo.enterEventDispatcher(); } /** Constructor. */ private CameraDemo() { CameraScreen screen = new CameraScreen(); pushScreen( screen ); } } /** * A UI screen to display the camera display and buttons. */ final class CameraScreen extends MainScreen { /** The camera's video controller. */ private VideoControl _videoControl; /** The field containing the feed from the camera. */ private Field _videoField; private Player player; /** An array of valid snapshot encodings. */ private EncodingProperties[] _encodings; /** * Constructor. Initializes the camera and creates the UI. */ public CameraScreen() { //Set the title of the screen. //setTitle( new LabelField( "Camera Demo" , LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH ) ); //Initialize the camera object and video field. initializeCamera(); //Initialize the list of possible encodings. initializeEncodingList(); //If the field was constructed successfully, create the UI. if(_videoField != null) { createUI(); } //If not, display an error message to the user. else { add( new RichTextField( "Error connecting to camera." ) ); } } /** * Adds the VideoField and the "Take Photo" button to the screen. */ private void createUI() { //Add the video field to the screen. add(_videoField); } /** * Initializes the Player, VideoControl and VideoField. */ private void initializeCamera() { try { //Create a player for the Blackberry's camera. player = Manager.createPlayer( "capture://video" ); //Set the player to the REALIZED state (see Player docs.) player.realize(); //Grab the video control and set it to the current display. _videoControl = (VideoControl)player.getControl( "VideoControl" ); if (_videoControl != null) { //Create the video field as a GUI primitive (as opposed to a //direct video, which can only be used on platforms with //LCDUI support.) _videoField = (Field) _videoControl.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field"); //Display the video control _videoControl.setDisplayFullScreen(true); _videoControl.setVisible(true); } //Set the player to the STARTED state (see Player docs.) player.start(); } catch(Exception e) { Dialog.alert( "ERROR " + e.getClass() + ": " + e.getMessage() ); } } /** * Create a screen used to display a snapshot. * @param raw A byte array representing an image. */ private void createImageScreen( byte[] raw ) { //Initialize the screen. ImageScreen imageScreen = new ImageScreen( raw ); //Push this screen to display it to the user. UiApplication.getUiApplication().pushScreen( imageScreen ); } /** * Handle trackball click events. * @see net.rim.device.api.ui.Screen#invokeAction(int) */ protected boolean invokeAction(int action) { boolean handled = super.invokeAction(action); if(!handled) { switch(action) { case ACTION_INVOKE: // Trackball click. { try { //A null encoding indicates that the camera should //use the default snapshot encoding. String encoding = null; // All the below result in a black screen being captured on OS6 devices // encoding = "encoding=jpeg&width=1024&height=768"; // encoding = "encoding=jpeg&width=1024&height=768&quality=superfine"; // encoding = _encodings[1].getFullEncoding(); // Null works but the image captured is large (~1MB) encoding = null; //Retrieve the raw image from the VideoControl and //create a screen to display the image to the user. createImageScreen(_videoControl.getSnapshot( encoding ) );//null works } catch(final Throwable e) { UiApplication.getUiApplication().invokeLater(new Runnable() { public void run() { Dialog.alert( "ERROR " + e.getClass() + ": " + e.getMessage() ); } }); } return true; } } } return handled; } /** * Prevent the save dialog from being displayed. * @see net.rim.device.api.ui.container.MainScreen#onSavePrompt() */ public boolean onSavePrompt() { return true; } /** * Initialize the list of encodings. */ private void initializeEncodingList() { try { //Retrieve the list of valid encodings. String encodingString = System.getProperty("video.snapshot.encodings"); //Extract the properties as an array of words. String[] properties = StringUtilities.stringToKeywords(encodingString); //The list of encodings; Vector encodingList = new Vector(); //Strings representing the four properties of an encoding as //returned by System.getProperty(). String encoding = "encoding"; String width = "width"; String height = "height"; EncodingProperties temp = null; for(int i = 0; i < properties.length ; ++i) { if( properties[i].equals(encoding)) { if(temp != null && temp.isComplete()) { //Add a new encoding to the list if it has been //properly set. encodingList.addElement( temp ); } temp = new EncodingProperties(); //Set the new encoding's format. ++i; temp.setFormat(properties[i]); } else if( properties[i].equals(width)) { //Set the new encoding's width. ++i; temp.setWidth(properties[i]); } else if( properties[i].equals(height)) { //Set the new encoding's height. ++i; temp.setHeight(properties[i]); } } //If there is a leftover complete encoding, add it. if(temp != null && temp.isComplete()) { encodingList.addElement( temp ); } //Convert the Vector to an array for later use. _encodings = new EncodingProperties[ encodingList.size() ]; encodingList.copyInto((Object[])_encodings); } catch (Exception e) { //Something is wrong, indicate that there are no encoding options. _encodings = null; } } protected boolean keyDown(int keycode, int time) { System.out.println("Input" + keycode + "/" + Keypad.key(keycode) + " C1 = " + Keypad.KEY_CONVENIENCE_1 + " C2 = " + Keypad.KEY_CONVENIENCE_2); if ( Keypad.key(keycode) == Keypad.KEY_CONVENIENCE_1 ) { return true; } return super.keyDown(keycode, time); } protected boolean keyChar(char c, int status, int time) { System.out.println("Input" + c + ":" + Keypad.getKeyCode(c, status)); switch (c) { case Characters.ESCAPE: this.close(); return true; default: return super.keyChar(c, status, time); } } }
Thanks for getting back to me.
It turns out that it was only a problem on the Simulator. I managed to get my hands on a real device 9780 and the code works fine on it.
-
System.getProperty returns NULL on Simulator
The following call:
System.getProperty("video.snapshot.encodings")
Returns a null value.
I tried using the default Simulator of the component package 4.5.0_4.5.0.16.
This key is available in 4.7 +. I don't know what you're trying to do, but you should know that there is no way to adjust the front camera of 4.6.
-
I'm trying to access the SD card on the Simulator.
I first 'change' SD card via the Simulation menu and specify a path name, that I have set up to be identical to the structure of the directory of the SD card.
Then, something I just found out, is that I have to get the name of the SD card.
System.getProperty tried to get the name of the root directory, and I got the following results.
The key string result
filecon.dir.MemoryCard null
filecon.dir.MemoryCard.Name null
Why do I get null for the name of the name of the SD card?
How to open a file on an SD card on the Simulator is - a. Is there anything else I need to put in place on the Simulator in addition to change SD card.
.. .where is this result telling me that the way to access the Blackberry directory on the SD card is to use the following:
file:///BlackBerry/
that is the SD card has no name... null?
Thank you
-Donald
I solved this myself (at least this part :-)
OK, for those of you who want to know how to open your media card correctly (at least in the storm).
First, make a call to System.getProperty ("fileconn.dir.memorycard");
This returns the string "file:///SDCard/".
Note that you are not guaranteed that the file system of the media card will always be SD card, so you should always call System.getProperty beforehand.
Then, if you use the Simulator, you must select the simulate change... SD card menu. This opens a small window allowing you to select different directories (by default is set to None, which means the media card is disconnected). You can click new folder to set the directory that emulates the directory root of the press card. You can enter several directories and it will remember them so you can switch from one to the other. The entry selected (highlighted) is used, so if you select none, it generates an event to remove media card.
You must also set the it strategy using strategy-simulation game IT... menu.
Under the tab control application, you must assign to allow local connections and all the other features that you will use. Similarly, the policy of COMPUTER you must select allow local connections and click on him-> the button to add to the list of policies. Also you must click on the set after that to define the it strategy.
OK, now you can open the connection to the file.
-Donald
-
Java 7 u45 System.getProperty returns null
After the upgrade to u45, our web launch application has stopped working. He failed System.getProperty ("myproperty").
"myproperty" is defined as an
< resources >
< j2se version = "+ 1.6" initial-heap-size = "64 m" max-heap-size = "256 m" / >
< jar href = "nms_wsclient.jar" Download = hand "impatient" = "true" / > "
< href = tΘlΘchargement jar "commons - httpclient.jar" = "forward" / >
< href = tΘlΘchargement jar "commons - codec.jar" = "forward" / >
< href = tΘlΘchargement jar "commons - logging.jar" = "forward" / >
< jar href = "log4j.jar" Download = "forward" / > "
"< property name ="myproperty"" value = "http://138.120.128.94:8085 /" / > ""
< / resource >
with old java version, System.getProperty ("myproperty") works very well to return the value, but with u45 it returns null.
Does anyone have the same problem? no idea how to fix or work around it?
Thank you
Zhongyao
7u45 made a change that is not documented in the release notes. You must precede the properties with jnlp.myproperty in your JNLP file, unless your jnlp file is signed.
But like me, since you can have different values in multiple deployments, signing the JNLP is impossible.
I tried to submit a bug on this issue report, but their bug report process works as well as 7u45...
-
HP officejet pro 8600 will not print documents
Printer is set up with Wi - Fi. When I try to print documents system does not see printer, even if it appears as a device in the Control Panel has Windows 7 Home Premium.
Hi Tombuck,
I see that you are having problems with your printer. I would try to help from Hp print and Scan doctor.
Let me know how it goes.
-
How to change the name of a system folder on the XP computer I currently own
I want to change the name of the system folder. When you open a file, it says the name of the document\ system I want to change\ folder locateing is the name. Please help me.
1 create a new user with administrator rightsAccounts start-settings-control panel - user - create a new user accountBe sure of what she had administrator rightselse log in to any user account that has administrator rightsStart-Run-type regedit-okHKEY_LOCAL_MACHINE \ logiciels\ Microsoft\ Windows NT------CurrentVersion \ ProfileListVerify that the list below, you will find ProfileImagePath on the right panelalso, you should find a %SystemDrive%\Documents and user name Settings\oldDouble-click the ProfileImagePath you can simply rename the last user name itand start-run - type %systemdrive%\Documents and Settings
change the old file nameIf you are in doubt click on this link below -
Can not read the Oracle JVM system property unless the class is reloaded
I want to be able to read system properties set of
DBMS_JAVA
.set_property of a java stored procedure. To do this, I have this simple code:public static String getEnvironmentVar(String propertyName) { return System.getProperty(propertyName); }
When I run the present on the database, java stored procedure does not seem to load the property just has
DBMS_JAVA
.set_property:declare s varchar2(100); begin s := dbms_java.set_property('test_prop', 'test_val'); s := getEnvironmentVar('test_prop'); -- This is my java stored proc dbms_output.put_line(s); end;
However, when I reload the class in Oracle (with loadjava); the property is read correctly. Am I missing something?
Thank you.
If you try the declare in a new session of RDBMS, I think you'll find that it works. Or insert the line
s: = dbms_java.endsession;
between the dbms_java.set_property and the getEnvironmentVar call. When dbms_java.set_property is called, it creates a value for a property that is used only for subsequent initializations of the java VM for this session of RDBMS. It does not affect the java VM that has already been initialized in the session, as appropriate. If java has not been used before that in the session underway, then the virtual machine will be initialized when the getEnvironmentVar call is made and the value established earlier by dbms_java.set_property discussed. But if java had already been used in the session, such as would happen if you had previously created or solved the class containing the method getEnvironmentVar of the session, then the value set by dbms_java.set_property is not visible (unless and until that something (like dbms_java.endsession, System.exit or an unrecoverable error) occurs to put an end to the existing java VM without end of the RDBMS session).
-
How to set up a system property
Hello world
Does anyone know how to set up a system console for WebLogic 11 g property?
I´d as set up a property via the web console, then get this property in my java code. Something like this:
System.getProperty ("foo");
Is this possible?
Thank you
FernandoHi Fernando,
Please see the link which tells us how we can define the JAVA_OPTIONS the administration Console...
http://WebLogic-wonders.com/WebLogic/2010/03/26/nodemanager-based-managedservers-setting-mem_args/
The link above demonstrate that how we define * "-the system Duser.dir property = E: / MyDirectory" *...Now you can set your own JAVA_OPTION as follows:
-Dfoo = MyFooValue
After setting above propertu in AdminConsole MEM ARGS, you must restart the server. Then, you can use the following code:
String result = System.getProperty ("foo");
.
.
Thank you
Jay SenSharma -
Hello
I try to transfer my code running under Sun JDK 6 in Jrockit (R28).
However, I am facing a problem of loading a library ('so') under JRockit which works very well under the Sun JVM.
The LD_LIBRARY_PATH setting is identical for the two JAVA VMs.
I wrote a class simpel, loading the library (in a file called libDiskCapacityUnix.so, located in/usr/mms/common/lib) just to test this device under two virtual machines Java is the code in the class:
public class MyClass {}
Public Shared Sub main (String [] args) {}
Path String is System.getProperty ("java.library.path");.
System.out.println ("Java.Library.Path =" + path);
System.loadLibrary ("DiskCapacityUnix");
System.out.println ("loading library DiskCapacityUnix succeeded");
}
}
Release of JRockit:
mms10: / var/tmp [113] /jrrt-4.0.0-1.6.0/bin/java MyClass
Java.Library.Path=/jrrt-4.0.0-1.6.0/jre/lib/sparcv9/JRockit:/jrrt-4.0.0-1.6.0/jre/lib/sparcv9:/jrrt-4.0.0-1.6.0/JRE/... /lib/sparcv9:/usr/lib/LWP:.:/ usr/mms/common/lib:/usr/cti/lib:/opt/oracle/product/11.2.0.1/instantclient_11_2:/opt/oracle/product/11.2.0.1/instantclient_11_2/lib32:/opt/oracle/product/11.2.0.1/instantclient_11_2/lib:/usr/local/lib:/usr/local/ssl/lib:/usr/lib:/jrrt-4.0.0-1.6.0//jre/lib/sparcv9:/jrrt-4.0.0-1.6.0//jre/lib/sparcv9/native_threads:/usr/local/mms/usr/local/lib:/usr/sfw/lib::/usr/lib
Exception in thread "Main Thread" java.lang.UnsatisfiedLinkError: no DiskCapacityUnix in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1689)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1029)
at MyClass.main (MyClass.java:7)
Sun's JAVA virtual machine output:
mms10: / var/tmp [123] / usr/mms/java/bin/java MyClass
Java.Library.Path=/usr/MMS/Java/JRE/lib/sparc/Server:/usr/MMS/Java/JRE/lib/sparc:/usr/MMS/Java/JRE/... /lib/sparc:/usr/lib/LWP:.:/ usr/mms/common/lib:/usr/cti/lib:/opt/oracle/product/11.2.0.1/instantclient_11_2:/opt/oracle/product/11.2.0.1/instantclient_11_2/lib32:/opt/oracle/product/11.2.0.1/instantclient_11_2/lib:/usr/local/lib:/usr/local/ssl/lib:/usr/lib:/jrrt-4.0.0-1.6.0//jre/lib/sparcv9:/jrrt-4.0.0-1.6.0//jre/lib/sparcv9/native_threads:/usr/local/mms/usr/local/lib:/usr/sfw/lib:.:/ usr/jdk/packages/lib/sparc: / lib: / usr/lib
Loading library DiskCapacityUnix succeededI'm guessing that your library is a 32-bit library? JRockit on sparc 64-bit only and cannot load 32-bit libraries.
/ Staffan
-
Migrating from JBoss to WebLogic 10.3: how to set the system property?
Hello
I am migrating from JBoss to WebLogic, and I need to define a global property.
What I need to do, is to link my path of the properties file for a global property accessible to all applications deployed on the server, in order to find the path of my applications (EJB 2.1) and access the properties without cutting the path of the properties file in the code.
In jboss, I used the file "properties - service.xml", in which I can set the key/value pairs, and the key will be published to the server and available programmatically as a property system through the call "System.getProperty ().
How can I do the same in weblogic 10.3?
Thank you!Yes
In both options... .reading the code in the file property will be the same.
Thank you
Jay SenSharma -
How can I get the UserAgent from my BlackBerry?
I want to get the UserAgent of the blackberry where my application is running. How do I remove this?
You cannot retrieve the user agent itself, but you can get some information for you to assemble and generate the user agent. I've already tested and it's the same as the user-agent sent by the RIM Browser.you can also make reference to this document.
You can use this one.
String userAgent = return "BlackBerry" + DeviceInfo.getDeviceName () + ' / ' +.
DeviceInfo.getSoftwareVersion () +.
"' Profile /" + System.getProperty ("microedition.profiles") + "
"Configuration /" + System.getProperty)
"microedition.configuration") + "" VendorID / ' + Branding. "
getVendorId();
-
Eception java.lang.error trying to create format XML string
I am trying to create XML documents without having to build everything manually whenever I want to do this. I created a XMLFile class to create the document. When I try to launch my app TestFoo, I get untrapped Exception java.lang.error. I tried kxml2, using org.w3c.dom, java XML, banging my head against the wall as to why it will not work until I finally just rolled my own simple implementation. I always get the error! No details are provided. There is no stack trace. I use the emulator 9000 "BOLD" crossing os 4.6.0 eclipse 3.4.1
Console:
Starting TestFooStarted TestFoo(154)Exit TestFoo(154)ErrorNo detail messageTestFoo Document
0x171TestFoo XMLFile 0x381TestFoo TestFoo 0x297TestFoo TestFoo main 0x276 TestFoo.java
import net.rim.device.api.system.Application; public class TestFoo extends Application { public static void main(String[] args) { TestFoo foo = new TestFoo(); foo.enterEventDispatcher(); } public TestFoo() { XMLFile xml = new XMLFile("rootNode"); xml.addProperty("myprop", "some value"); System.out.println(xml.toFormattedXMLString()); System.exit(0); }}
XMLFile.java
public class XMLFile { Document document; public XMLFile(String rootElement) { document = new Document(rootElement); } public void addProperty(String pName, String pText) { Element elm = new Element("property"); elm.addAttribute("name", pName); elm.setTextContent(pText); document.appendChild(elm); } public String toFormattedXMLString() { return document.toFormattedXML(); }}
Element.Java
import java.util.Enumeration;import java.util.Hashtable;import java.util.Vector; public class Element { private Vector children; private String name; private String textContent; private Hashtable attributes; public Element(String name) { this.children = new Vector(); this.attributes = new Hashtable(); this.name = name; } public void appendChild(Element child) { this.children.addElement(child); } public Vector getChildren() { return children; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getTextContent() { return textContent; } public void setTextContent(String textContent) { this.textContent = textContent; } public Hashtable getAttributes() { return attributes; } public boolean hasChildren() { return (this.children.size() > 0); } public int childrenCount() { return this.children.size(); } public String getAttributeValue(String name) { return this.attributes.get(name).toString(); } public void addAttribute(String key, String value) { this.attributes.put(key, value); } public void addAttribute(String key, int value) { addAttribute(key,Integer.toString(value)); } public void addAttribute(String key, long value) { addAttribute(key,Long.toString(value)); } public void addAttribute(String key, boolean value) { addAttribute(key, String.valueOf(value)); } public boolean hasAttribute(String name) { return this.attributes.containsKey(name); } public Element getChild(int position) { return (Element) this.children.elementAt(position); } public Enumeration getAttributeKeys() { return this.attributes.keys(); }}
Document.Java
import java.util.Enumeration; public class Document { private static final char _gt = '>'; private static final char _lt = '<'; private static final char _eq = '='; private static final char _dqt = '"'; private static final char _cl = '/'; private static final char _sp = ' '; private static final char _tab = '\t'; private static final byte[] _nl = System.getProperty("line.separator").getBytes(); private Element rootNode; private StringBuffer sb; public Document(String rootName) { this.rootNode = new Element(rootName); } public void appendChild(Element child) { this.rootNode.appendChild(child); } public String toFormattedXML() { sb = new StringBuffer(); format(this.rootNode,0); return sb.toString(); } private void format(Element node, int depth) { writeOpenTag(node, depth); for (int i=0;i
0;i--) { sb.append(_tab); } } private void writeOpenTag(Element node, int depth) { indent(depth); sb.append(_lt); sb.append(node.getName()); for (Enumeration keys = node.getAttributeKeys();keys.hasMoreElements();) { String key = keys.nextElement().toString(); sb.append(_sp).append(key); sb.append(_eq).append(_dqt); sb.append(node.getAttributeValue(key).toString()); sb.append(_dqt); } } private void writeCloseTag(Element node, int depth) { if (node.hasChildren()) { sb.append(_lt).append(node.getName()); } else { sb.append(_cl); } sb.append(_gt).append(_nl); }} This line:
private static final byte[] _nl = System.getProperty("line.separator").getBytes();
is originally a NullPointerException because line.separator is not well supported. The line terminator standard for XML is CR/LF, so you can use:
private static final byte[] _nl = { '\r', '\n' };
-
Bidi text JTextPane and JTextArea changes the row height
You can use the following example to demonstrate the problem. When you run, copy and paste an Arab character of http://www.alanwood.net/unicode/arabic.html in the display area. This creates a condition of bidi in the document. The circumflex replaces one with a flag at the top to indicate ownership LTR or RTL of the character. The height of the display line, going at a lower height. I am able to detect the State of bidi. I can't get any action to indicate what was the change of line height. I've exhausted all measuring height of possible line that I could find. The size reported by all methods does not State non-bidi bidi State, even if the row height is significantly reduced. Anyone else encounter this? Any proven way to measure the difference?
to import javax.swing.JFrame;
Import javax.swing.JTextPane;
public class HelloSwing {}
Public Shared Sub main (String [] args) {}
JFrame frame = new JFrame ("HelloWorldSwing");
OSname string = new String();
OSname = System.getProperty ("os.name");
JTextPane tp = new JTextPane();
frame.getContentPane () .add (tp);
tp.setText (OSname);
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
Frame.Pack ();
frame.setSize (400, 200);
frame.setLocationByPlatform (true);
frame.setVisible (true);
}
}I think that Eclipse does not use JEditorPane but own component. GUI editors has monospaced fonts of equal width/height for each tank and fixed a height for all rows. It is much easier to manage several sizes of fonts on the same line.
-
Please help:
goal: find the URL of the document in which the applet is embedded
Attempt: Applet class and Getdocumentbase() or GetCodeBase method used in the creation of JDeveloper PJC
Problem: Compilation error wrong method - a dynamic method can be used in static context
The code as follows
package oracle.forms.fd;
import java.net.InetAddress;
import java.io.InputStream;
import java.io.BufferedInputStream;
import java.io.IOException;
to import java.text.ParseException;
import java.util.StringTokenizer;
import java.applet.Applet;
Import oracle.forms.ui.VBean;
Import oracle.forms.handler.IHandler;
Import oracle.forms.properties.ID;
/ public final class AppletInfos extends kifani
{
………..
…………….
………..
private final static ID DIP = ID.registerProperty ("DIP");
private final static MAC ID is ID.registerProperty ("MAC");.
………………..
………………
private String some days in Paris ="";
private String sMAC = "";
Private boolean Arnaud = false;
public void init (Manager IHandler)
{
Super.init (Handler);
try {}
Some days in Paris = Applet.getCodeBase ();
sMAC = getMacAddress();
} catch (Throwable t) {}
t.printStackTrace ();
}
}
public Object getProperty (pId No.)
{
if(PID == GETINFOS)
{
sInfos += "\nMAC address:" + sMAC.
return of sInfos;
}
else if(pId == DIP) return some days in Paris;
else if(pId == MAC) return sMAC;
Return super.getProperty (pId);
}
Private final public static String getMacAddress() throws IOException {}
The os string = System.getProperty ("os.name");
try {}
{if (OS. StartsWith ("Windows"))}
Return windowsParseMacAddress (windowsRunIpConfigCommand ());
}
else {if (os.startsWith ("Linux"))
Return linuxParseMacAddress (linuxRunIfConfigCommand ());
}
else {}
throw new IOException ("unknown operating system:" + os);
}
} catch (ParseException ex exception) {}
ex.printStackTrace ();
throw new IOException (ex.getMessage ());
}
}
/*
* Linux stuff
*/
Private final public static String linuxParseMacAddress (String ipConfigResponse) throws ParseException {
String localHost = null;
try {}
localHost = InetAddress.getLocalHost () .getHostAddress ();
} catch (exception java.net.UnknownHostException ex) {}
ex.printStackTrace ();
throw new ParseException (ex.getMessage (), 0);
}
StringTokenizer tokenize = new StringTokenizer (ipConfigResponse, "\n");
String lastMacAddress = null;
{while (tokenizer.hasMoreTokens ())}
String line = tokenizer.nextToken (.trim ());
Boolean containsLocalHost = line.indexOf (localHost) > = 0;
If the line contains the IP address
If (containsLocalHost & & lastMacAddress! = null) {}
Return lastMacAddress;
}
If the line contains the MAC address
int macAddressPosition = line.indexOf ("HWaddr");
If (macAddressPosition < = 0) Then continues
String macAddressCandidate = line.substring (macAddressPosition + 6) .trim ();
{if (linuxIsMacAddress (macAddressCandidate))}
lastMacAddress = macAddressCandidate;
continue;
}
}
ParseException ex = new ParseException
("cannot read the MAC address for" + localHost + "from [" + ipConfigResponse + ""] ", 0");
ex.printStackTrace ();
throw ex;
}
{private static final boolean linuxIsMacAddress (String macAddressCandidate)
TODO: use a smart regular expression
If (macAddressCandidate.length ()! = 17) return false;
Returns true;
}
Private final public static String linuxRunIfConfigCommand() throws IOException {}
Process p is Runtime.getRuntime () .exec ("ifconfig");.
InputStream stdoutStream = new buffer (p.getInputStream ());
StringBuffer buffer = new StringBuffer();
for (;) {
int c = stdoutStream.read ();
If (c ==-1) break;
buffer. Append ((Char) c);
}
String outputText = buffer.toString ();
stdoutStream.close ();
return outputText;
}
/*
* Windows stuff
*/
Private final public static String windowsParseMacAddress (String ipConfigResponse) throws ParseException {
String localHost = null;
try {}
localHost = InetAddress.getLocalHost () .getHostAddress ();
} catch (exception java.net.UnknownHostException ex) {}
ex.printStackTrace ();
throw new ParseException (ex.getMessage (), 0);
}
StringTokenizer tokenize = new StringTokenizer (ipConfigResponse, "\n");
String lastMacAddress = null;
{while (tokenizer.hasMoreTokens ())}
String line = tokenizer.nextToken (.trim ());
If the line contains the IP address
If (Line.EndsWith (localHost) & & lastMacAddress! = null) {}
Return lastMacAddress;
}
If the line contains the MAC address
int macAddressPosition = line.indexOf(":");
If (macAddressPosition < = 0) Then continues
String macAddressCandidate = line.substring (macAddressPosition + 1) .trim ();
{if (windowsIsMacAddress (macAddressCandidate))}
lastMacAddress = macAddressCandidate;
continue;
}
}
ParseException ex = new ParseException ("can not read MAC addresses from [" + ipConfigResponse + "]", 0);
ex.printStackTrace ();
throw ex;
}
{private static final boolean windowsIsMacAddress (String macAddressCandidate)
TODO: use a smart regular expression
If (macAddressCandidate.length ()! = 17) return false;
Returns true;
}
Private final public static String windowsRunIpConfigCommand() throws IOException {}
Process p is Runtime.getRuntime () .exec ("ipconfig/all");.
InputStream stdoutStream = new buffer (p.getInputStream ());
StringBuffer buffer = new StringBuffer();
for (;) {
int c = stdoutStream.read ();
If (c ==-1) break;
buffer. Append ((Char) c);
}
String outputText = buffer.toString ();
stdoutStream.close ();
return outputText;
}
}Hello
There are a number of errors in your code. Here's the corrected version that works:
package oracle.forms.fd;
import java.net.InetAddress;
import java.io.InputStream;
import java.io.BufferedInputStream;
import java.io.IOException;
to import java.text.ParseException;
import java.util.StringTokenizer;
import java.applet.Applet;
Import oracle.forms.ui.VBean;
Import oracle.forms.handler.IHandler;
Import oracle.forms.properties.ID;/ public final class AppletInfos extends kifani
{private final static ID DIP = ID.registerProperty ("DIP");
private final static MAC ID is ID.registerProperty ("MAC");.
private final static GETINFOS ID is ID.registerProperty ("GETINFOS");.private String some days in Paris ="";
private String sMAC = "";
Private boolean Arnaud = false;
public void init (Manager IHandler)
{
Super.init (Handler);
try {}
Some days in Paris = handler.getApplet () .getCodeBase () .getHost ();
sMAC = getMacAddress();
} catch (Throwable t) {}
t.printStackTrace ();
}
}
public Object getProperty (pId No.)
{
if(PID == GETINFOS)
{
Return "\nMAC address:" + sMAC.}
else if(pId == DIP) return some days in Paris;
else if(pId == MAC) return sMAC;
Return super.getProperty (pId);
}Private final public static String getMacAddress() throws IOException {}
The os string = System.getProperty ("os.name");
try {}
{if (OS. StartsWith ("Windows"))}
Return windowsParseMacAddress (windowsRunIpConfigCommand ());
}
else {if (os.startsWith ("Linux"))
Return linuxParseMacAddress (linuxRunIfConfigCommand ());
}
else {}
throw new IOException ("unknown operating system:" + os);
}
} catch (ParseException ex exception) {}
ex.printStackTrace ();
throw new IOException (ex.getMessage ());
}
}
/*
* Linux stuff
*/
Private final public static String linuxParseMacAddress (String ipConfigResponse) throws ParseException {
String localHost = null;
try {}
localHost = InetAddress.getLocalHost () .getHostAddress ();
} catch (exception java.net.UnknownHostException ex) {}
ex.printStackTrace ();
throw new ParseException (ex.getMessage (), 0);
}
StringTokenizer tokenize = new StringTokenizer (ipConfigResponse, "\n");
String lastMacAddress = null;
{while (tokenizer.hasMoreTokens ())}
String line = tokenizer.nextToken (.trim ());
Boolean containsLocalHost = line.indexOf (localHost) > = 0;
If the line contains the IP address
If (containsLocalHost & lastMacAddress! = null) {}
Return lastMacAddress;
}
If the line contains the MAC address
int macAddressPosition = line.indexOf ("HWaddr");
If (macAddressPosition<= 0)="">=>
String macAddressCandidate = line.substring (macAddressPosition + 6) .trim ();
{if (linuxIsMacAddress (macAddressCandidate))}
lastMacAddress = macAddressCandidate;
continue;
}
}
ParseException ex = new ParseException
("cannot read the MAC address for ' + 'from' localHost, 0);
ex.printStackTrace ();
throw ex;
}
{private static final boolean linuxIsMacAddress (String macAddressCandidate)
TODO: use a smart regular expression
If (macAddressCandidate.length ()! = 17) return false;
Returns true;
}
Private final public static String linuxRunIfConfigCommand() throws IOException {}
Process p is Runtime.getRuntime () .exec ("ifconfig");.
InputStream stdoutStream = new buffer (p.getInputStream ());
StringBuffer buffer = new StringBuffer();
for (;) {
int c = stdoutStream.read ();
If (c ==-1) break;
buffer. Append ((Char) c);
}
String outputText = buffer.toString ();stdoutStream.close ();
return outputText;
}
/*
* Windows stuff
*/
Private final public static String windowsParseMacAddress (String ipConfigResponse) throws ParseException {
String localHost = null;
try {}
localHost = InetAddress.getLocalHost () .getHostAddress ();
} catch (exception java.net.UnknownHostException ex) {}
ex.printStackTrace ();
throw new ParseException (ex.getMessage (), 0);
}
StringTokenizer tokenize = new StringTokenizer (ipConfigResponse, "\n");
String lastMacAddress = null;{while (tokenizer.hasMoreTokens ())}
String line = tokenizer.nextToken (.trim ());If the line contains the IP address
If (Line.EndsWith (localHost) & lastMacAddress! = null) {}
Return lastMacAddress;
}If the line contains the MAC address
int macAddressPosition = line.indexOf(":");
If (macAddressPosition<= 0)="">=>String macAddressCandidate = line.substring (macAddressPosition + 1) .trim ();
{if (windowsIsMacAddress (macAddressCandidate))}
lastMacAddress = macAddressCandidate;
continue;
}
}ParseException ex = new ParseException ("cannot read the MAC address of", 0);
ex.printStackTrace ();
throw ex;
}
{private static final boolean windowsIsMacAddress (String macAddressCandidate)
TODO: use a smart regular expression
If (macAddressCandidate.length ()! = 17) return false;Returns true;
}
Private final public static String windowsRunIpConfigCommand() throws IOException {}
Process p is Runtime.getRuntime () .exec ("ipconfig/all");.
InputStream stdoutStream = new buffer (p.getInputStream ());StringBuffer buffer = new StringBuffer();
for (;) {
int c = stdoutStream.read ();
If (c ==-1) break;
buffer. Append ((Char) c);
}
String outputText = buffer.toString ();stdoutStream.close ();
return outputText;
}
}
Make sure:
(1) refer to your bean (implementation class) as: oracle.forms.fd.AppletInfos
(2) use the get_custom_property built-in for your info:
For example:
: B1. MAC: = Get_Custom_Property (' B1.) TEXTAREA', 1, 'MAC');
: B1. DIP: = Get_Custom_Property (' B1.) TEXTAREA', 1, 'DIP');
Please note that there is a property GETINFOS that was not declared in your code and added. You can change it if you wish.
(3) you must sign your jar file. Check the webutil on your developer installation directory for an example.Hafed
www.degenio.comPublished by: mhafod on January 24, 2009 23:26
If you want to see the changes that I made, please make a diff. Thank you.
Maybe you are looking for
-
Update graphics Equium L350 - 10L
Hi, I'm wanting to improve the graphics on my laptop, graphics, maps I've seen in stores are for desktop computers only. I said the graphics card is integrated on the motherboard, can I and how to pass it and what it will cost? Thank you
-
Remote compilation through Windows target
I have a 8108 Windows controller in a pxi-7830R 1042 q a chassis in slot 2. I have my development machine connected to the 8108 through a network switch. My goal is to create the project on my development machine and compile the fpga from here. I cre
-
When I put my desktop background, the image is off center to the right
Ideas: just past slot explore 7 explore 8 You have problems with programs Error messages Recent changes to your computer What you have already tried to solve the problem Remember - this is a public forum so never post private information such as numb
-
Hello team, Does anyone has a software that can give the ip address for any device connected to the laptop, as the Council of access control? Thanks for help
-
Increase the quality of the screenshots in the cutting tool?
I mean, it is, can capture shears which are a quality jpeg image (higher resolution?) higher. I make videos using a tinsmith shear quality is poor. Thank you!