DOM Parsing Not working in Applet.

Hi,
I ve an applet (parserapplet)which contains the DOM parsing. So xalan.jar(nearly 780 kb) required to assist the parsing. I gave archive="xalan.jar" in My html file. But the jar file is not downloaded from the archive tag. and ClassnotFoundException is thrown.
the exact exception is:
======================
com.ms.security.SecurityExceptionEx[Host]: cannot access file C:\WINNT\Java\lib\jaxp.properties
     at com/ms/security/permissions/FileIOPermission.check
     at com/ms/security/PolicyEngine.deepCheck
     at com/ms/security/PolicyEngine.checkPermission
     at com/ms/security/StandardSecurityManager.chk
     at com/ms/security/StandardSecurityManager.checkRead
     at java/io/File.exists
     at javax/xml/parsers/DocumentBuilderFactory.findFactory
     at javax/xml/parsers/DocumentBuilderFactory.newInstance
     at parserapplet.parseXMLMessage
     at parserapplet.init
     at com/ms/applet/AppletPanel.securedCall0
     at com/ms/applet/AppletPanel.securedCall
     at com/ms/applet/AppletPanel.processSentEvent
     at com/ms/applet/AppletPanel.processSentEvent
     at com/ms/applet/AppletPanel.run
     at java/lang/Thread.run
javax.xml.parsers.FactoryConfigurationError: java.lang.ClassNotFoundException: org/apache/crimson/jaxp/DocumentBuilderFactoryImpl
     at javax/xml/parsers/DocumentBuilderFactory.newInstance
     at parserapplet.parseXMLMessage
     at parserapplet.init
     at com/ms/applet/AppletPanel.securedCall0
     at com/ms/applet/AppletPanel.securedCall
     at com/ms/applet/AppletPanel.processSentEvent
     at com/ms/applet/AppletPanel.processSentEvent
     at com/ms/applet/AppletPanel.run
     at java/lang/Thread.run
I know signing the applet a bit. But though it is signed , second exception is constantly thrown. so please write in detail the procedure to sign the applet. and how to download xalan.jar in html page etc.,
I require how to download the jar files, and after the completion of downloading of the jar files only, the applet should get executed. or shall i use different jar file(like crimson.jar?). This is urgent requirement.Please help me.!
the classes for the parsing are not at all downloaded and hence the problem.
help me reg that.
thank you in advance/.
Prasanna kumar k.

Hello Prasanna kumar k.
First you should sign your jar files (xerces.jar crimson.jar and xalan.jar) and recreate a cab files
xerces.cab crimson.cab xalan.cab. To do that you should download sdk for java from microsoft .
create testkey named testkey.pvk
1. makecert -sv testkey.pvk -n "CN=your name" test.cer
convert to public key
2. cert2spc test.cer test.spc :
create cab file
3. cabarc -p -c -r -s 6144 test.cab
sign the cab file
4. signcode -j java.dll -jp -low -spc -v testkey.pvk -n test.cab
after that you should use thia files in html:
<!doctype html public "//W3//DID HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META content="text/html; charset=iso-8859-1">
<TITLE>IBM Host On-Demand 6.0</TITLE>
</HEAD>
<BODY BACKGROUND="mankolpr/custom/img/Drawing1.gif">
<CENTER>
<IMG src="mankolpr/custom/img/images/ot_hod_log.gif">
<P>
<APPLET archive="crimson.jar,xerces.jar,xalan.jar" CODE="test.class" WIDTH=584 HEIGHT=450>
<PARAM NAME=cabinets VALUE=crimson.cab,xerces.cab,xalan.cab>
<PARAM NAME=background VALUE="pink">
<p>If you are reading this message, your client platform is not capable of running
IBM Host On-Demand. To run IBM Host On-Demand, you must have a Java-enabled web
browser such as Netscape Navigator or Microsoft Internet Explorer.
</APPLET>
</CENTER>
</BODY>
</HTML>
Best Regards,
Tzur Emzari
Project Manager
Local Authority Data Processing Center LTD
ISRAEL
Tel : 972-4-8615754, Fax : 972-4-8661977
Cell : 972-53-532448
[email protected] <mailto:[email protected]>

Similar Messages

  • Comm.jar not working in Applet but works in Eclipse

    Hello,
    Please help me to read serial port data from Java Applet.
    The below code working well and get data from weighing machine when we run in eclipse(Run Applet). But it now working when we use class file in Applet.
    I think its security issue, but i still could not understand what we need to do.
    I put the JOptionPane.showDialog and found that the code is crashing in line CommPortIdentifier.getPortIdentifiers(); (Not understood why try catch not working.)
    I am using in Windows 7 environment.
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.event.*;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.Enumeration;
    import java.util.logging.Logger;
    import javax.comm.*;
    import javax.swing.*;
    public class SimpleApplet extends JApplet {
    public void init() {
    JButton button = new JButton("Click me!");
    button.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent evt) {                 
         JOptionPane.showMessageDialog(SimpleApplet.this, "hello");
    JOptionPane.showMessageDialog(SimpleApplet.this, Getdata());
    add(button, BorderLayout.CENTER);
    setBackground(Color.GRAY);
    public String Getdata()
         try
              String drivername = "com.sun.comm.Win32Driver";
    try
    CommDriver driver = (CommDriver) Class.forName(drivername).newInstance();
    driver.initialize();
    catch (Exception e) { //just do nothing, it doesn't really matter
         Enumeration portList=null;
    CommPortIdentifier portId;
    SerialPort serialPort;
    OutputStream outputStream;
    try
         portList = CommPortIdentifier.getPortIdentifiers();
    }catch(Exception ex)
         JOptionPane.showMessageDialog(SimpleApplet.this, "erorr:" + ex.getStackTrace().toString());
    JOptionPane.showMessageDialog(SimpleApplet.this, "get port lsit");
              while(portList.hasMoreElements())
                   portId = (CommPortIdentifier) portList.nextElement();
                   if(portId.getPortType()== CommPortIdentifier.PORT_SERIAL)
                        if(portId.getName().equals("COM1"))
                             try
                                  serialPort = (SerialPort) portId.open("WeightMachine",200);                              
                                  serialPort.setSerialPortParams(1200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
                                  outputStream = serialPort.getOutputStream();
                                  InputStream mInputFromPort = serialPort.getInputStream();
                                  outputStream.write("W".getBytes());
                                  outputStream.flush();
                                  Thread.sleep(500);
                                  byte mBytesIn [] = new byte[20];
                                  mInputFromPort.read(mBytesIn);
                                  //mInputFromPort.read(mBytesIn);
                                  String value = new String(mBytesIn);
                                  mInputFromPort.close();
                                  serialPort.close();
                                  return value.replace("+00", "").replace(" Kg", "");
                             }catch(Exception ex)
                                  return ex.getMessage();
              }catch(Exception ex)
                   JOptionPane.showMessageDialog(SimpleApplet.this, "erorr last:" + ex.getStackTrace().toString());
              return "Not found";
    Thanks in advance.
    Avinash

    959817 wrote:EJP wrote:959817 wrote:
    it now working when we use class file in Applet.Define 'not working'.But when i run applet from browser from same machine its not working.That's not an answer. That's just a vague and pointless restatement of the original vague and pointless statement that I asked you to clarify.
    When you take your car to a mechanic, do you just tell him it's 'not working'?

  • ActionPerformed method not working when applet is loaded in browser window.

    Hey there guys. I need urgent help from anybody who has experience in deploying websites whose code is in java.
    I am having two problems as mentioned below...
    first, I have made a simple login screen using java swing and JApplet. there is a single button to login. the action performed for this button accesses a private method to check the username and password which are there in atext file. the applet is working perfectly in appletviewer but when i load the applet in a Internet Explorer window using HTML's Applet tag, the button is giving no response at all even when i enter the correct username and password.
    I guess it is either not calling the private function that is checking the username and password from the tes=xt file or it can not access the file. Please help as soon as possible as this is related to my college project.
    I am attaching the code herewith. Suggestions to improve the coding are also welcome.
    the second problem is that while writing my second program for generating a form which registers a user the html is not at all loading the applet into the browser and also if im trying to access a file to write all the details into the console is showing numerous amount of error after i press the button which i can't not understand. the only thing i can understand is that it is related to file access permissions. If anybody could put some light on the working of worker threads and thread safe activities of SwingUtilities.invokeandWait method it would be really appreciable.
    import java.io.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.plaf.*;
    <applet code = "UserLogin" width = 300 height = 150>
    </applet>
    public class UserLogin extends JApplet implements ActionListener, KeyListener {
         private JLabel lTitle;
         private JLabel lUsername, lPassword;
         private JTextField tUsername;
         private JPasswordField tPassword;
         private JButton bLogin;
         private JLabel lLinkRegister, lLinkForgot;
         private JLabel lEmpty = new JLabel(" ", JLabel.CENTER);
         private JPanel panel1, panel2;
         public void init() {
              try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                   SwingUtilities.invokeAndWait(new Runnable() {
                        public void run() {
                             LoginGUI();
              catch(Exception e) {
                   e.printStackTrace();
         public void start() {
              setVisible(true);
         public void stop() {
              setVisible(false);
         private void LoginGUI() {
              super.setSize(300, 150);
              super.setBackground(Color.white);
              lTitle = new JLabel("<HTML><BODY><FONT FACE = \"COURIER NEW\" SIZE = 6 COLOR = BLUE>Login</FONT></BODY></HTML>", JLabel.CENTER);
              lUsername = new JLabel("Username : ", JLabel.CENTER);
              lPassword = new JLabel("Password : ", JLabel.CENTER);
              tUsername = new JTextField(15);
              tPassword = new JPasswordField(15);
              bLogin = new JButton("LOGIN");
    //          bLogin.setEnabled(false);
              bLogin.addActionListener(this);
              bLogin.addKeyListener(this);
              panel2 = new JPanel();
              GridBagLayout gbag = new GridBagLayout();
              GridBagConstraints gbc = new GridBagConstraints();
              panel2.setLayout(gbag);
              panel2.addKeyListener(this);
              gbc.anchor = GridBagConstraints.CENTER;
              panel2.setMinimumSize(new Dimension(300, 200));
              panel2.setMaximumSize(panel2.getMinimumSize());
              panel2.setPreferredSize(panel2.getMinimumSize());
              gbc.gridx = 1;
              gbc.gridy = 1;
              gbag.setConstraints(lUsername,gbc);
              panel2.add(lUsername);
              gbc.gridx = 2;
              gbc.gridy = 1;
              gbag.setConstraints(tUsername,gbc);
              panel2.add(tUsername);
              gbc.gridx = 1;
              gbc.gridy = 2;
              gbag.setConstraints(lPassword,gbc);
              panel2.add(lPassword);
              gbc.gridx = 2;
              gbc.gridy = 2;
              gbag.setConstraints(tPassword,gbc);
              panel2.add(tPassword);
              gbc.gridx = 2;
              gbc.gridy = 3;
              gbag.setConstraints(lEmpty,gbc);
              panel2.add(lEmpty);
              gbc.gridx = 2;
              gbc.gridy = 4;
              gbag.setConstraints(bLogin,gbc);
              panel2.add(bLogin);
              panel1 = new JPanel(new BorderLayout());
              panel1.add(lTitle, BorderLayout.NORTH);
              panel1.add(panel2, BorderLayout.CENTER);
              add(panel1);
              setVisible(true);
         public void keyReleased(KeyEvent ke) {}
         public void keyTyped(KeyEvent ke) {}
         public void keyPressed(KeyEvent ke) {
              if(ke.getKeyCode() == KeyEvent.VK_ENTER){
                   String username = tUsername.getText();
                   String password = new String(tPassword.getPassword());
                   if(username.length() == 0 || password.length() == 0) {
                        JOptionPane.showMessageDialog(new JFrame(),"You must enter a username and password to login", "Error", JOptionPane.ERROR_MESSAGE);
                   else {
                        boolean flag = checkUsernamePassword(username, password);
                        if(flag)
                             JOptionPane.showMessageDialog(new JFrame(),"Username and Password Accepted", "Access Granted", JOptionPane.INFORMATION_MESSAGE);
                        else
                             JOptionPane.showMessageDialog(new JFrame(),"Username or password Incorrect", "Access Denied", JOptionPane.INFORMATION_MESSAGE);
         public void actionPerformed(ActionEvent ae) {
              String gotCommand = ae.getActionCommand();
              if(gotCommand.equals("LOGIN")) {
                   String username = tUsername.getText();
                   String password = new String(tPassword.getPassword());
                   if(username.length() == 0 || password.length() == 0) {
                        JOptionPane.showMessageDialog(new JFrame(),"You must enter a username and password to login", "Error", JOptionPane.ERROR_MESSAGE);
                   else {
                        boolean flag = checkUsernamePassword(username, password);
                        if(flag)
                             JOptionPane.showMessageDialog(new JFrame(),"Username and Password Accepted", "Access Granted", JOptionPane.INFORMATION_MESSAGE);
                        else
                             JOptionPane.showMessageDialog(new JFrame(),"Username or password Incorrect", "Access Denied", JOptionPane.INFORMATION_MESSAGE);
         private boolean checkUsernamePassword(String username, String password) {
              String user = null, pswd = null;
              try {
                   FileInputStream fin = new FileInputStream("@data\\userpass.txt");
                   DataInputStream din = new DataInputStream(fin);
                   BufferedReader brin = new BufferedReader(new InputStreamReader(din));
                   user = (String) brin.readLine();
                   pswd = (String) brin.readLine();
              catch(IOException ioe) {
                   ioe.printStackTrace();
              if(username.equals(user) && password.equals(pswd))
                   return true;
              else
                   return false;
    }PLEASE HELP ME GUYS......

    RockAsh wrote:
    Hey Andrew, first of all sorry for that shout, it was un-intentional as i am new to posting topics on forums and didn't new that this kind of writing is meant as shouting. Cool.
    Secondly thank you for taking interest in my concern.No worries.
    Thirdly, as i mentioned before, I am reading i file for checking of username and password. the file is named as "userpass.txt" and is saved in the directory named "@data" which is kept in the same directory in which my class file resides.OK - server-side. That makes some sense, and makes things easier. The problem with your current code is that the applet will be looking for that directory on the end user's local file system. Of course the file does not exist there, so the applet will fail unless the the end user is using the same machine as the server is coming from.
    To get access to a resource on the server - the place the applet lives - requires an URL. In applets, URLs are relatively easy to form. It might be something along the lines of
    URL urlToPswrd = new URL(getCodeBase(), "@data/userpass.txt");
    InputStream is = urlToPswrd.openStream();
    DataInputStream din = new DataInputStream(is);
    So the problem is that it is reading the file and showing the specific output dialog box when i run it through appletviewer.. Huhh. What version of the SDK are you using? More recent applet viewers should report security exceptions if the File exists.
    ..but the same is not happening when i launch the applet in my browser window using the code as written belowHave you discovered how to open the Java Console in the browser yet? It is important.
    Also the answer to your second question
    Also, the entire approach to storing/restoring the password is potentially wrong. For instance, where is it supposed to be stored, on the server, or on the client?is that, as of now it is just my college project so all the data files and the username and password wiles will be stored on my laptop only i.e. on the client only. no server involved.OK, but understand that an applet ultimately does not make much sense unless deployed through a server. And the entire server/client distinction becomes very important, since that code would be searching for a non-existent file on the computer of the end user.

  • Dynamic Action on DOM object not working

    Thru a dynamic action I am executing PL/SQL Code that creates additional item using APEX_ITEM.CHECKBOX (see code on bottom). Thru another Dynamic action, I am trying to execute additional Java. I have it set to fire like this:
    Event: Click
    Type: DOM Object
    DOM Object: document.forms[0].f11 (this matches the APEX_ITEM.checkbox fxx value)
    Just trying a simple alert("hi"). doesn't work. Am I missing something?
    DECLARE
    l_hold_table_name varchar2(1000) := :P1223_HOLD_TABLE_NAME;
    l_hold_html varchar2(32000) := '';
    l_hold_session_state varchar2(32000) := '';
    CURSOR get_columns IS
    select b.column_heading, b.column_name
    from dual
    BEGIN
    l_hold_html := '<DIV><TABLE border="2"><THEAD><TR><TH>' || l_hold_table_name ||
    '</TH></TR></THEAD>';
    FOR x in get_columns LOOP
    l_hold_html := l_hold_html || '<TR><TD>' || APEX_ITEM.CHECKBOX(20,x.column_name,null) || x.column_heading || '</TD></TR>';
    END LOOP;
    l_hold_html := l_hold_html || '</TABLE><DIV>';
    :P1223_HOLD_INNERHTML := l_hold_html;
    END;

    Hi,
    first your code in example does not compile.
    CURSOR get_columns IS
    select b.column_heading, b.column_name
    from dual
    There is a ; missing and even with that this query is not OK.
    If you have a problem with DOM selector, then try jquery selector:
    Event:Click
    Selection Type: jQuery Selector
    jQuery Selector: input:checkbox[name*='f11']
    For testing I created a test page with one dynamic PLSQL region and following source:
    DECLARE
      l_hold_table_name varchar2(1000) := 'MYTABLE';
      l_hold_html varchar2(32000) := '';
      l_hold_session_state varchar2(32000) := '';
      CURSOR get_columns IS
      select
        'My Checkbox' column_heading, 'a' column_name
      from dual ;
    BEGIN
      l_hold_html := '<TABLE border="2"><THEAD><TR><TH>'
                              || l_hold_table_name
                              || '</TH></TR></THEAD>';
      FOR x in get_columns LOOP
        l_hold_html := l_hold_html ||
                                '<TR><TD>' ||
                                APEX_ITEM.CHECKBOX(20,x.column_name,null) ||
                                x.column_heading ||
                                '</TD></TR>';
      END LOOP;
      l_hold_html := l_hold_html || '</TABLE>';
      htp.p( l_hold_html );
    END;And Dynamic Action with properties as described above (only that in my case name of the checkbox is f20)
    You can see working example here : http://apex.oracle.com/pls/apex/f?p=60428:4
    Regards,
    Aljaz
    Edited by: Aljaz on 5.3.2012 22:36

  • Class path for parser not working

    The following were not found in my import when i build the program:
    import org.w3c.dom.*;
    import org.xml.sax.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    I thought this problem would be solved by having a SAX parser(sax2r2).
    I set the class path as follows:
    SET PATH=%PATH%;%JAVAHOME%\BIN
    PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;
    C:\jdk1.3\lib\bin
    C:\jdk1.3\lib\sax2r2.jar;
    sax2r2.jar is placed in the correct folder.
    What could be the problem?
    Cheers

    You set the PATH like that. If you want to set the CLASSPATH then you need to set the CLASSPATH variable.

  • Apache Tika PDF Parser not working in CQ 5.6

    Hi all,
    I was using following code to extract text from PDF in a CQ package.
    ContentHandler handler = new BodyContentHandler();
    Parser parser = new PDFParser();
    parser.parse(a.getOriginal().getStream(), handler, new Metadata(),
    new ParseContext());
    String text = handler.toString();
    This works perfectly in CQ 5.5 but in CQ 5.6 I get following exception:
    Caused by: java.lang.ClassNotFoundException: org.apache.pfbox.io.RandomAccess not found by org.apache.tika.parsers [58]
              at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringI mpl.java:1499)
              at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
              at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl. java:1882)
              at java.lang.ClassLoader.loadClass(Unknown Source)
    Any ideas on why this class is not being found ?
    Thanks!

    Thanks!
    I changed the code to:
    Tika tika = new Tika();
    Reader reader = tika.parse(a.getOriginal().getStream());
    This works in CQ 5.5 and CQ 5.6 both

  • Sandbox Security Issue (MIDI Not Working In Applet)

    Hi all,
    I'm having problems getting javax.sound.midi to work in a java applet. It works fine when I run the applet from within JGrasp, but when I try to run the applet from an HTML file there is no sound. From what info I've found, it seems like my problem has to do with the sandbox security so the applet is not being able to access the computer's sound card, but I still haven't found a solution or a work around to that problem (after about 2 weeks worth of searching). The world of applet security is all new territory for me.
    I am running the html file off of my hard drive and I have my test program's class file in the same directory. I have tried both firefox and internet explorer web browsers (and also did the "allow blocked content" in internet explorer).
    I have no other sound sources playing or paused that would interfere with the web browser playing (it works in JGrasp and immediately after closing JGrasp completely it doesn't work in the web browser).
    Any help help in getting this figured out would be greatly appreciated. An example of an open source MIDI Java applet that I can pick apart to figure out what I need to make this work would be fantastic. Thanks in advance!
    Here are the codes to my test program and HTML file:
    PlayMIDI.html
    <html>
    <body>
    <CENTER><applet code="PlayMIDI.class" width="1000" height="500"></applet></CENTER>
    </body>
    </html>PlayMIDI.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.net.*;
    import javax.sound.midi.*;
    public class PlayMIDI extends JApplet
        public void init()
            MIDITest play = new MIDITest(0);
            play.playSong(100);
    class MIDITest
        private final int C4 = 60;                                        // C4 is the note middle C
        private final int MF = Integer.MAX_VALUE / 2;        // MF stands for mezzo forte -- medium loud
        private int iTimbre;                                                 // midi instrument number
        private Synthesizer synth;                                        // get the java synthesizer
        private MidiChannel [] channels;                              // get an array of channels.  This is the number of notes that can sound simultaneously     
        // Creates a midi synthisizer using the supplied instrument "patch".
        //   instrument numbers can vary from 0 to 127
        public MIDITest(int instrumentNumber)
            iTimbre = instrumentNumber;
            try 
            {   synth = MidiSystem.getSynthesizer();                                   //synth = MidiSystem.getSynthesizer();
                synth.open();                                                                           // open the synthesizer
                synth.loadAllInstruments(synth.getDefaultSoundbank());     // make all instruments available
                channels = synth.getChannels();
                channels[0].programChange(0, iTimbre);                                   // set the instrument for the channel 0
            catch (Exception e)
            {  System.out.println(e);
        public void playSong(int tempo)
            int quarter     = 60000;
            int eigth     = 30000;
            int half          = 120000;
            int whole     = 240000;
            int D4 = C4 + 2;
            int E4 = C4 + 4;
            int G4 = C4 + 7;
            int A4 = C4 + 9;
            int B4 = C4 + 11;
            try
            {   channels[0].noteOn(E4, MF);                         // start the instrument on channel 0 sounding
                channels[0].noteOn(B4, MF);
                channels[0].noteOn(G4, MF);
                channels[0].noteOn(D4, MF);
                Thread.sleep(whole / tempo);                         // sleep causes the program to wait the given number of milliseconds
                channels[0].noteOff(E4, MF);                         // stop the sound on the instrument on channel 0
                channels[0].noteOff(B4, MF);
                channels[0].noteOff(G4, MF);
                channels[0].noteOff(D4, MF);
            catch (Exception e)
            {   System.out.println(e);
    }

    Hi ejp, thanks for the reply.
    I did some searching for applet signing and I found this:
    http://www.brendonwilson.com/projects/signed-java/
    "+Developers should be warned that signing alone is not enough to enable their Java applets to access resources normally restricted by the Java sandbox. Although signing provides proof of the integrity of the applet and validation of the author’s identity through trust-heirarchies, developers must also make use of the browser-dependent APIs to request permission from the user to perform restricted activities.+"
    So am I going to have to do ask permission from each browser in order to get access to the sound card for the MIDI to play or will the MIDI work without that?
    Also, I found this tutorial on signing applets. Does this look like a good one?
    http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html
    Thanks again,
    -tkr

  • String parsing not working in Java

    hi I am using the following code to construct a string and i see that it seems that the correct string is made but the application does not run
    if i just cut n paste the same string into command prompt it works fine . please advise :
    also note iam costructing string in two way , but using stringbuffer and by using + , but both ways dont work.
    public static void main(String args[]) {
    String s = null;
    // system command to run
    String quotes="\"";
    String parameter = quotes + args[0] + quotes;
    String cmd = "awtrap -f 10.200.16.17 -h 10.100.10.112 -p 162 -c fdot 1.3.6.1.4.1.791.2.9.2 6 4 1.3.6.1.4.1.791.2.9.2 -s " + parameter;
    System.out.println(cmd);
    File workDir = new File("/opt/CA/SharedComponents/ccs/atech/services/bin");
    StringBuffer sb = new StringBuffer();
    sb.append("awtrap -f 10.200.16.17 -h 10.100.10.112 -p 162 -c fdot 1.3.6.1.4.1.791.2.9.2 6 4 1.3.6.1.4.1.791.2.9.2 -s ");
    sb.append("\"");
    sb.append(args[0]);
    sb.append("\"");
    String str2 = sb.toString();
    System.out.println(str2);
    try {
    Process p = Runtime.getRuntime().exec(cmd, null, workDir);
    ========================================== below is the run log ============================================
    awtrap -f 10.200.16.17 -h 10.100.10.112 -p 162 -c fdot 1.3.6.1.4.1.791.2.9.2 6 4 1.3.6.1.4.1.791.2.9.2 -s "testing 2"
    awtrap -f 10.200.16.17 -h 10.100.10.112 -p 162 -c fdot 1.3.6.1.4.1.791.2.9.2 6 4 1.3.6.1.4.1.791.2.9.2 -s "testing 2"
    usage: /opt/CA/SharedComponents/ccs/atech/services/bin/awtrap [-v 1 | 2c | 3] [-i] [-r retries] [-f from_addr | from_host]
    [-h dest_addr | dest_host] [-p port] [-t timeout ] [-d logLevel]
    [-c community] enterprise type [subtype] [oid oidtype value]
    ================================= now if I just cut n paste the string on command prompt it runs fine =====================
    Pt$ awtrap -f 10.200.16.17 -h 10.100.10.112 -p 162 -c fdot 1.3.6.1.4.1.791.2.9.2 6 4 1.3.6.1.4.1.791.2.9.2 -s "testing 2"
    Pt$

    sahmad43 wrote:
    Saber did you take a look at my code? I am building array using two methods , and i dont wont to try the third for no reason,You are building a string not an array. My experience is that the array approach generally has less problems than the single string approach and is easier to debug.
    please read my post I am asking the question clearly dont want to repeat it here again.I spent some time with your OP making sure I understood your problem - you should read my post again. I'm am showing you an alternative to the single string approach that I have found very successful. Now you can just ignore my advice, which is based on considerable experience, and continue on in your blinkered way. I don't have the problem so I don't care
    >
    thanksBye

  • Jstl xml parser not working

    i cant seem to be able to select the values from the imported xml file and i dont understand why?
    my jsp page:
    <%@ page import="java.util.*;" %>
    <%@ page contentType="text/html; charset=ISO-8859-5" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <html>
    <head>
        <title>Interactive Experience Database - Template 1</title>
        <LINK REL="STYLESHEET" TYPE="text/css" HREF="style.css">
    </head>
    <body>
    <FORM>
    <c:import var="xmlfile" url="/cv.xml"/>
    <x:parse var="doc" xml="${xmlfile}"/>
    <x:out select="$doc/cv/ContactInfo/PersonName"/>
    </form>
    </body>
    </html>the xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE cv>
    <cv>
    <ContactInfo>
         <PersonName>Donald Smith</PersonName>
    </ContactInfo>
    </cv>

    thanks, one thing that annoys me is that that apache
    make it so hard to download anything, finding the
    binary is so time consuming, ive been looking for the
    last half hour. its a jokeI kind of agree with you that for certain projects it is a little difficult to find the stable release of the binaries. I personally find it very time consuming to locate the binary for JSTL 1.1 , and finding the binary for Xalan seems a little more easier than finding the one for JSTL 1.1
    For Xalan I was quickly able to locate it through google:
    Searched for "download apache xalan" , then Google showed me
    http://xml.apache.org/xalan-j/downloads.html then I clicked on :
    http://www.apache.org/dyn/closer.cgi/xml/xalan-j
    ~~~~~~~~~~~~~~~~~~~~~~
    But for JSTL 1.1 it took quite a number of steps :
    Searched on Google for : "download JSTL 1.1"
    First link showed:
    http://java.sun.com/products/jsp/jstl/downloads/index.html
    Shows the link for Standard 1.0 instead of Standard 1.1
    (A newbie to JSTL wouldn't know that there's a 1.1 final release download available)
    another link for the same keywords takes me to:
    http://jakarta.apache.org/taglibs/
    Then I click on downloads: http://jakarta.apache.org/taglibs/#Downloads
    but it only shows Nightly Builds downloads not the stable release ones.
    Then I click on JSTL1.1 on the left nav takes me to
    http://jakarta.apache.org/taglibs/doc/standard-doc/intro.html
    The download link finally takes me to:
    http://people.apache.org/builds/jakarta-taglibs/nightly/
    which is again nightly
    Then I carefully read and finally see:
    Download the Binary Distribution of the Final Release:
    http://jakarta.apache.org/site/downloads/index.html
    Then I click on TagLibs
    http://jakarta.apache.org/site/downloads/downloads_taglibs.html
    and pick Standard 1.1 Tag lib (assuming that is JSTL 1.1)
    http://jakarta.apache.org/site/downloads/downloads_taglibs-standard.cgi
    I guess I could report this issue to Apache Taglibs and have them make it more efficient to locate the download for the Taglibs.

  • Mouse Drag is not working in Applets

    In our application we are using applets in containing in IFRAMES in IE to display different type of graphs and animations etc. User can open/close these Applets and iframes to navigate from one data view to other. During this navigation sometimes mouse drag event stops and all drag related operations like scrolls etc stops responding to drag operations in all applets in same JVM.
    My investigation shows that swing component hierarchy gets corrupted somehow and this exception is thrown
    EventMulticaster.eventDispatched(Toolkit.java:2244)
         at java.awt.Toolkit.notifyAWTEventListeners(Toolkit.java:2203)
         at java.awt.Component.dispatchEventImpl(Component.java:4528)
         at java.awt.Container.dispatchEventImpl(Container.java:2099)
         at java.awt.Component.dispatchEvent(Component.java:4460)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4603)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4255)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
         at java.awt.Container.dispatchEventImpl(Container.java:2085)
         at java.awt.Component.dispatchEvent(Component.java:4460)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
         at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    peerComponents in Container class is returning null on call to getLocationOnScreen that causes this exception.
    I fixed the issue in awt library but ORACLE license terms don't allow redistribution of modified version of awt.
    Please help me fix this issue in applet code or suggest me to bypass license restrictions.
    Thanks in advance!
    Luqman

    877922 wrote:
    peerComponents in Container class is returning null on call to getLocationOnScreen that causes this exception.
    I fixed the issue in awt library but ORACLE license terms don't allow redistribution of modified version of awt.Something Oracle do allow is to raise a bug report. On that report they invite you to post a work-around or fix. That would be the place to put the fix you have devised. Oracle will (supposedly) fix it, then you (and everyone else) can enjoy the fix as a free upgrade in the next version.
    They also offer 'support contracts' (AFAIU) in which you might pursue your own immediate fixes. But raise the bug report anyway.

  • Scrolling not working in applet

    I'm a Java/Applet/Swing newbie and I have run into the following problem. I can't seem to make an applet with a JEditorPane in a JScrollPane scroll programmatically. If I click on the editor pane and enter text, it scrolls, but setCaretPosition() or scrollToReference() don't seem to have any effect. I would be very grateful if anyone could tell me what is wrong with the following simplified code that exhibits the problem and how should I correct it.
    Thanks,
    Mike
    ===================
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import java.net.*;
    public class SourceTest extends JApplet {
           JEditorPane editorPane;
           String newline = "\n";
           String sourceCode;
           public void start() {
             sourceCode = new String("<html><body><pre>");
             for(int i = 0; i < 1000; i++) {
                sourceCode += "x<br>";
             sourceCode += "</pre></body></html>";
            editorPane = new JEditorPane("text/html", sourceCode);
            editorPane.setEditable(false);
            JScrollPane scrollPane = new JScrollPane(editorPane);
            //Add Components to the Applet.
            Container contentPane = getContentPane();
            contentPane.add(scrollPane);
    // *** Try to scroll, but it doesn't work
            editorPane.setCaretPosition(400);
    }

    I have something similar in an applet working just fine. I do the scroll pane logic a bit differently:
    JScrollPane myScrollPane = new JScrollPane();
    myPanel.add(myScrollPane, BorderLayout.CENTER);
    myScrollPane.getViewport().add(myEditorPane, null);
    First stmt is straight forward. Second stmt is just adding the scroll pane to the panel -- also straight forward. Third statement is the one that is different than the way you do it.
    Hope that helps. If it doesn't, let me know and I'll copy your code and try to fix it.

  • Need help in getting common DOM API to work

    Grettings, all -
    I'm up against the wall. I have spend a lot of time trying to get Common DOM API to work to no avial. So far I tried it with Netscape 6.2.3, Mozilla 1.0 and MSIE 6. My problem is that while I get non-null Document, all calls on it return null. Here is the code snippet I have:
    public class Foo extends Applet {
    Applet m_appletThis;
    StringBuffer m_sbuf;
    public void init() {
    m_appletThis = this;
    m_sbuf = new StringBuffer();
    addItem("initializing... ");
    try {
    JSObject jsWin = JSObject.getWindow(this);
    JSObject jsDoc = (JSObject)jsWin.getMember("document");
    String sName = (String)jsDoc.getMember("name");
    Object oLocation = (JSObject)jsDoc.getMember("location");
    addItem("location=" + oLocation);
    String sTitle = (String)jsDoc.getMember("title");
    addItem("title=" + sTitle);
    addItem("initialized! ");
    catch (JSException e) {
    e.printStackTrace();
    public void start() {
    addItem("starting... ");
    DOMService ds = null;
    try {
    ds = DOMService.getService(this);
    String sTitle = (String)ds.invokeAndWait(new DOMAction() {
    public Object run(DOMAccessor da) {
    Document doc = da.getDocument(m_appletThis);
    return doc.getNodeValue();
    addItem(sTitle);
    // let's try again
    Document doc = (Document)ds.invokeAndWait(new DOMAction() {
    public Object run(DOMAccessor da) {
    Document doc;
    NamedNodeMap nnm;
    Node node;
    doc = (Document)da.getDocument(m_appletThis);
    nnm = doc.getAttributes();
    NodeList nl = doc.getChildNodes();
    if (null == nl)
    addItem("no children!");
    else
    for (int i = 0; i < nl.getLength(); i++) {
    node = nl.item(i);
    addItem((null == node) ?
    ("no node" + i) : node.getNodeName());
    if (null == nnm)
    addItem("no attribs!");
    else {
    node = nnm.getNamedItem("location");
    if (null == node)
    addItem("no node!");
    else
    addItem(node.getNodeValue());
    return doc;
    catch (DOMUnsupportedException e1) {
    e1.printStackTrace();
    catch (DOMAccessException e2) {
    e2.printStackTrace();
    addItem("started! ");
    public void stop() {
    addItem("stopping... ");
    public void destroy() {
    addItem("preparing for unloading...");
    void addItem(String newWord) {
    System.out.println(newWord);
    m_sbuf.append(newWord + "\r\n");
    repaint();
    public void paint(Graphics g) {
    Dimension dim = getSize();
    //Draw a Rectangle around the applet's display area.
    g.drawRect(0, 0, dim.width - 1, dim.height - 1);
    //Draw the current string inside the rectangle.
    g.drawString(m_sbuf.toString(), 5, 15);
    This produces the following output:
    initializing...
    location=file:///foo.bar.html
    title=
    initialized!
    starting...
    null
    no children!
    no attribs!
    started!
    As starting/started lines show all of my attempts to get access to browsers DOM fail.
    I will really appreciate any advice you can provide. Thanks in advance.
    - Andrew

    hi,
    i desperately tried similar things and, after studying some forum entries, it seems to me that common dom DOES NOT WORK...
    sorry for us, but bugparade promises to fix that in 1.4.2 (somewhen in 2003 :-( )
    if you need dom-access try jsobject or the ibm directDOM-technology, that seems to work much better..
    greets,
    dirk

  • HT5559 Java web start does not work

    I have followed the instructions in this article, including the last step about web start, but it still does not work, neither applets or web start. When I try to launch a JWS application by double clicking it I get the dreaded warning dialog:
    To open this Web Start application, you need to download the Java Runtime Environment.
    Click “More Info…” to visit the website for the Java Runtime Environment.
    I do have a JRE installed, 1.6, since I for compatibility reasons can't upgrade.
    Trying to launch a web start application from the commandline looks like this:
    $ javaws /tmp/airview.jnlp
    Java Web Start splash screen process exiting ...
    Can not find message file: No such file or directory
    Regular Java-programs work fine.
    $ java -version
    java version "1.6.0_37"
    Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
    Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)

    Read this thread https://discussions.apple.com/thread/4789691?tstart=0
    This fixed the issue for me:
    sudo /usr/libexec/PlistBuddy -c "Delete :JavaWebComponentVersionMinimum" /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/XProtect.meta. plist
    In the comments to the linked article someone suggests to comment out the node in stead of deleting it. Probably safer (it's explained further down how to do that). Anyway I already spent to much time on this nonsense, deleted it and it worked, so I'm happy.

  • Web Cam applet is not working in great consistency

    Hi... My video capturing applet is not working very well.
    The image stream is displayed on the web page in JPEG format with 0.5 quality. However, it crashes after a while and the it does not release the vfw resource.
    I have to restart my machine in order to execute it again.
    Can anyone please help?
    Thanks.
    Carter

    Ok. Thanks.
    Sender Applet
    import javax.swing.*;
    import java.io.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    /*<applet code="myGUIApplet.class" width="300" height="300"></applet>*/
    public class myGUIApplet extends JApplet implements ActionListener
         private JPanel bottom=new JPanel();
         private JPanel centVisual=new JPanel();
         private JPanel connectionAddress=new JPanel();
         private JButton capture=new JButton("Start Capturing");
         private JButton stops=new JButton("Stop");
         private JMenuBar menubar=new JMenuBar();
         private JMenu file=new JMenu("file");     
         private JMenuItem fileItem1=new JMenuItem("Exit");
         private JLabel serverip=new JLabel("Server IP");
         private JTextField setIP=new JTextField();
         public static JTextField ServerInfo=new JTextField();
         private MyTransmitter mytrans;
         private String ip;
         public static final String DEFAULT_MULTICAST_IP="226.10.10.20";
         public static final String DEFAULT_PORT="80";
         public void init()
              //setSize(400,400);               
              setLayout(new BorderLayout());
              menubar.add(file);
              file.add(fileItem1);
              bottom.setLayout(new BorderLayout());
              bottom.setBackground(Color.black);
              bottom.add("West",capture);
              bottom.add("East",stops);
              connectionAddress.setLayout(new BorderLayout());
              connectionAddress.add("North",serverip);
              connectionAddress.add("South",setIP);
              ServerInfo.setEditable(false);
              connectionAddress.add("Center",ServerInfo);
              setIP.addActionListener(this);
              setIP.setText("");
              capture.setBackground(Color.lightGray);
              capture.addActionListener(this);
              stops.addActionListener(this);
              fileItem1.addActionListener(this);
              add("South",bottom);
              add("North",menubar);     
              add("Center",connectionAddress);          
         public void actionPerformed(ActionEvent ae){
              Object source=ae.getSource();
              if(source==capture){
              if(setIP.getText().equals(""))
                        ip=DEFAULT_MULTICAST_IP;
              else{
                   ip=setIP.getText();
                   if(mytrans!=null){
                        mytrans.stopTransmitter();
                        mytrans=null;                         
                   System.out.println(" - Connecting to "+ip+" port: "+DEFAULT_PORT);
                   ServerInfo.setText(" - Connecting to "+ip+" port: "+DEFAULT_PORT);
                   mytrans=new MyTransmitter(ip,DEFAULT_PORT,ServerInfo);
                   mytrans.start();               
              if(source==stops){
                   if(mytrans!=null)
                        mytrans.stopTransmitter();
                   System.exit(0);
              if(source==fileItem1){
                   if(mytrans!=null)
                        mytrans.stopTransmitter();     
                   System.exit(0);
         public void destroy(){
              if(mytrans!=null){
                   mytrans.stopTransmitter();
    import java.awt.*;
    import javax.swing.*;
    import java.io.*;
    import java.util.*;
    import java.net.InetAddress;
    import javax.media.*;
    import javax.media.protocol.*;
    import javax.media.protocol.DataSource;
    import javax.media.format.*;
    import javax.media.control.TrackControl;
    import javax.media.control.QualityControl;
    import javax.media.rtp.*;
    import javax.media.rtp.rtcp.*;
    import javax.media.rtp.*;
    import java.io.InputStream;
    import javax.media.rtp.RTPManager;
    public class MyTransmitter extends Thread
         private MediaLocator videoLocator;
         private String ipAddress;
         private int basePort;
         private Integer stateLock=new Integer(0);
         private boolean failure;
         private Processor processor;
         private DataSource videoDataInput,videoDataOutput;
         private RTPManager rtpMgrs[];
         private VideoFormat JPEG_VIDEO=new VideoFormat(VideoFormat.JPEG_RTP);
         private SendStream sendStream;
         private SourceDescription descriptionList[];
         private JTextField infoField;
         public MyTransmitter(String ips,String ports,JTextField ServerInfo){
              infoField=ServerInfo;
              ipAddress=ips;
              Integer bPort=Integer.valueOf(ports);
              if(bPort!=null)
                   basePort=bPort.intValue();
         public void run()
              initializeVideo();
              if(videoLocator!=null){
                   createMyProcessor();
                   createMyManager();
              // May be should put inside the if..else statements
              //createMyTransmitter();
         // Initailize the video
         public void initializeVideo()
              // Stre the devices in a vector
              VideoFormat format=new VideoFormat(VideoFormat.RGB);
              Vector deviceList=CaptureDeviceManager.getDeviceList(format);
              CaptureDeviceInfo deviceInfo=null;
              // If there is more than one device detected
              if(deviceList.size()>0){
                   // Set the first device to device Info
                   // GEt the media locator of the devie
                   deviceInfo=(CaptureDeviceInfo)deviceList.elementAt(0);
                   videoLocator=deviceInfo.getLocator();
              }else{
                   System.out.println(" --X No device found...");
                   infoField.setText(" --X No device found...");
         public void createMyProcessor()
              boolean result=false;
              DataSource ds=null;
              // Check if the media locator is null
              if(videoLocator==null){
                   System.out.println(" --X No video locator..");
                   infoField.setText(" --X No video locator...");
              System.out.println(" - Trying to create a Processor..");
              infoField.setText(" - Trying to create a Processor..");
              // Attempt to create DataSource from media locator
              try{
                   ds=Manager.createDataSource(videoLocator);
              }catch(Exception ex){
                   System.out.println(" --X Unable to create dataSource : "+ex.getMessage());
              System.out.println(" - Video data source is created..");
              infoField.setText(" - Video data source is created..");
              // Try to create Processor from DataSource
              try{
                   processor=Manager.createProcessor(ds);
              }catch(NoProcessorException npe){
                   System.out.println(" --X Unable to create Processor: "+npe.getMessage());
                   infoField.setText(" --X Unable to create Processor: "+npe.getMessage());
              catch(IOException ioe){
                   System.out.println(" --X IOException creating Processor..");
                   infoField.setText(" --X IOException creating Processor..");
              // Wait for the processor to be configured
              result=waitForState(processor,Processor.Configured);
              if(result==false){
                   System.out.println(" --X Could not configure processor..");
                   infoField.setText(" --X Could not configure processor..");
              // Set the track controls for processor
              TrackControl []tracks=processor.getTrackControls();
              if(tracks==null || tracks.length<1){
                   System.err.println(" --X No track is found..");
                   infoField.setText(" --X No track is found..");
              // Set the content description of processor to RAW_RTP format
              // This will limit the supported formats to reported from
              // Track.getSupportedFormats() to valid RTP format
              ContentDescriptor cdes=new ContentDescriptor(ContentDescriptor.RAW_RTP);
              processor.setContentDescriptor(cdes);
              Format []supported;
              Format chosen=null;
              boolean atLeastOneTrack=false;
              for(int i=0;i<tracks.length;i++){
                   Format format=tracks.getFormat();
                   if(tracks[i].isEnabled()){
                        supported=tracks[i].getSupportedFormats();
                        // WE've set the output content to RAW_RTP.
                        // So, all the supporte formats should work with RAW_RTP.
                        // We will pick the first one.
                        if(supported.length>0){
                             if(supported[0] instanceof VideoFormat){                              
                                  chosen=checkVideoSize(tracks[i].getFormat(),supported[0]);
                             }else
                                  chosen=supported[0];
                             tracks[i].setFormat(chosen);
                             System.out.println(" Track "+i+" is transmitted in "+chosen+" format.. ");
                             infoField.setText(" Track "+i+" is transmitted in "+chosen+" format.. ");
                             atLeastOneTrack=true;
                        }else{
                             // If no format is suitable, track is disabled
                             tracks[i].setEnabled(false);
                   }else
                        tracks[i].setEnabled(false);          
              if(!atLeastOneTrack)
                   System.out.println("atLeastOneTrack: "+atLeastOneTrack);
                   System.out.println(" --X Could Not find track to RTP format..");
                   infoField.setText("atLeastOneTrack: "+atLeastOneTrack);
                   infoField.setText(" --X Could Not find track to RTP format..");
              result=waitForState(processor,Controller.Realized);
              if(result==false){
                   System.out.println(" --X Could NOT realize processor...");
                   infoField.setText(" --X Could NOT realize processor...");
              // Set the JPEG Quality to value 0.5
              setJPEGQuality(processor,0.5f);
              // Set the output Data Source
              videoDataOutput=processor.getDataOutput();
              //Start the processor
              processor.start();          
         public void setJPEGQuality(Processor p,float values)
              Control []cs=p.getControls();
              QualityControl qc=null;
              VideoFormat JPEGFmt=new VideoFormat(VideoFormat.JPEG);
              // Loop through the ocntrols to find the Quality control for the JPEG encoder
              for(int i=0;i<cs.length;i++){
                   if(cs[i] instanceof QualityControl && cs[i] instanceof Owned){
                        Object owner=((Owned)cs[i]).getOwner();
                        // Check if the owner is the Codec
                        // Check the format of output as well
                        if(owner instanceof Codec){
                             Format fmts[]=((Codec)owner).getSupportedOutputFormats(null);
                             // Loop through the supported format and set the quality to 0.5
                             for(int j=0;j<fmts.length;j++){
                                  qc=(QualityControl)cs[i];
                                  qc.setQuality(values);
                                  System.out.println(" - Quality is set to "+values+" on "+qc);
                                  infoField.setText(" - Quality is set to "+values+" on "+qc);
                                  break;
                   if(qc!=null)
                        break;
         public Format checkVideoSize(Format originalFormat,Format supported)
              int width,height;
              Dimension size=((VideoFormat)originalFormat).getSize();     
              Format jpegFormat=new Format(VideoFormat.JPEG_RTP);
              Format h263fmt=new Format(VideoFormat.H263_RTP);
              if(supported.matches(jpegFormat)){
                   width=(size.width%8 == 0 ? size.width:(int)(size.width%8)*8);
                   height=(size.height%8 == 0 ? size.height:(int)(size.height%8)*8);
              }else if(supported.matches(h263fmt)){
                   if(size.width<128){
                        width=128;
                        height=96;
                   }else if(size.width<176){
                        width=176;
                        height=144;
                   }else{
                        width=352;
                        height=288;
              }else{
                   // Unknown format, just return it.
                   return supported;
              return (new VideoFormat(null,new Dimension(width,height),Format.NOT_SPECIFIED,null,Format.NOT_SPECIFIED)).intersects(supported);
         public boolean waitForState(Processor p,Integer status)
              p.addControllerListener(new StateListener());
              failure=false;
              if(status==Processor.Configured){
                   p.configure();               
              }else if(status==Processor.Realized){
                   p.realize();
              //Wait until an event that confirms the success of the method, or failure of an event
              while(p.getState()<status && !failure){
                   synchronized(getStateLock()){
                        try{
                             // Wait
                             getStateLock().wait();
                        }catch(InterruptedException ie){
                             return false;
              if(failure)
                   return false;
              else
                   return true;
         public Integer getStateLock(){
              return stateLock;
         public void setFailure(){
              failure=true;
         public void createMyManager()
              SessionAddress destAddress;
              InetAddress ipAddr;
              int port;
              SourceDescription srcDesList[];
              PushBufferDataSource pbds=(PushBufferDataSource)videoDataOutput;
              PushBufferStream pbss[]=pbds.getStreams();          
              rtpMgrs=new RTPManager[pbss.length];          
              for(int a=0;a<pbss.length;a++){
              try{
                   // RTP Managers or RTP Manager?????
                   rtpMgrs[a]=RTPManager.newInstance();
                   port=basePort;
                   ipAddr=InetAddress.getByName(ipAddress);
                   SessionAddress localAddr=new SessionAddress(InetAddress.getLocalHost(),port+20);
                   destAddress=new SessionAddress(ipAddr,port,1);
                   Integer myipprefix=Integer.valueOf(ipAddress.substring(0,3));
                   if((myipprefix.intValue()>223) && (myipprefix.intValue()<240)){
                        rtpMgrs[a].initialize(destAddress);
                   }else{
                        rtpMgrs[a].initialize(localAddr);
                   rtpMgrs[a].addTarget(destAddress);
                   System.out.println(" Created RTP session: "+ipAddress+" "+port+" to "+destAddress);
                   infoField.setText(" Created RTP session: "+ipAddress+" "+port+" to "+destAddress);
                   if(videoDataOutput!=null){
                        sendStream=rtpMgrs[a].createSendStream(videoDataOutput,0);
                        sendStream.start();
                        System.out.println(" RTP stream is started..");
                        infoField.setText(" RTP stream is started..");
              }catch(UnsupportedFormatException ex){
                   System.out.println(" --X Unsupported Format : "+ex);
                   infoField.setText(" --X Unsupported Format : "+ex);
              catch(IOException ioe){
                   System.out.println(" --X IOException : "+ioe.getMessage());
                   infoField.setText(" --X IOException : "+ioe.getMessage());
              catch(Exception ex){
                   System.out.println(" --X Unable to create RTP Manager...");
                   System.out.println(ex.getMessage());
                   infoField.setText(" --X Unable to create RTP Manager..."+ex.getMessage());
         /*public void createMyTransmitter()
         try{
              if(videoDataOutput!=null){
                   sendStream=rtpMgrs[i].createSendStream(videoDataOutput,0);
                   sendStream.start();
         }catch(UnsupportedFormatException ex){
                   System.out.println(" --X Unsupported Format : "+ex);
                   infoField.setText(" --X Unsupported Format : "+ex);
         catch(IOException ioe){
                   System.out.println(" --X IOException : "+ioe.getMessage());
                   infoField.setText(" --X IOException : "+ioe.getMessage());
         public void stopTransmitter(){
              if(processor!=null){
                   processor.stop();
                   processor.close();
                   processor=null;
                   // Loop through RTP Managers and close all managers..
                   // Dispose them for garbage collection
                   for(int i=0;i<rtpMgrs.length;i++){
                        rtpmgrs[i].removeSendStream(this);
                        rtpMgrs[i].removeTargets("Session ended..");
                        rtpMgrs[i].dispose();
                   //rtpMgrs.removeTargets("Session ended..");
                   //rtpMgrs.dispose();
         * StateListener class to handle Controller events
         class StateListener implements ControllerListener{
              public void controllerUpdate(ControllerEvent ce){
                   if(ce instanceof ControllerClosedEvent){
                        processor.close();
                   /* Handle all controller events and notify all
                   waiting thread in waitForState method */
                   if(ce instanceof ControllerEvent){
                        synchronized(getStateLock()){
                             getStateLock().notifyAll();
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    Client Applet
    import javax.media.*;
    import javax.media.protocol.*;
    import javax.media.protocol.DataSource;
    import javax.media.control.BufferControl;
    import javax.media.control.*;
    import javax.media.format.*;
    import javax.media.rtp.*;
    import javax.media.rtp.rtcp.*;
    import javax.media.rtp.event.*;
    import com.sun.media.rtp.RTPSessionMgr;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import java.io.*;
    import java.net.*;
    import java.net.URL;
    import java.net.Socket;
    /*<applet code="clientPlayerApplet.class" width="400" height="300">
         <param name=ServerIPS value="192.168.0.9">
         <param name=ServerPort value="80">
         <param name=TimeToLive value="1">
         <param name=archive value="clientPlayerApplet.jar">
    </applet> */
    public class clientPlayerApplet extends JApplet implements ControllerListener, ReceiveStreamListener,SessionListener
         String sessions[]=null;
         RTPManager rtpmgrs[]=null;     
         boolean dataReceived=false;
         Object myDataSync=new Object();
         private Player player;
         //private String serveripadd="226.10.10.20";
         //private int serverPort=2020;
         //private int timeToLive=1;
         private JPanel panel;
         private Vector currentParticipant;
         public void init()
              panel=new JPanel();
              setLayout(new BorderLayout());
              add("Center",panel);
              //String[] urls;
              /*urls[0]=getParameter("ServerIPS");
              urls[1]="/";
              urls[2]=getParameter("ServerPort");*/
              String []urls={new String(getParameter("ServerIPS")+"/"+getParameter("ServerPort")+"/"+getParameter("TimeToLive"))};
              sessions=urls;          
              initializePlayer();
         public void initializePlayer(){
              try{
                   InetAddress ipAddr;
                   SessionAddress localAddr=new SessionAddress();
                   SessionAddress destAddr;
                   rtpmgrs=new RTPManager[sessions.length];
                   currentParticipant=new Vector();
                   //rtpmgrs=new RTPManager();
                   SessionLabel session=null;
                   //Open RTP session
                   for(int i=0;i<sessions.length;i++){
                        try{
                             session=new SessionLabel(sessions[i]);
                             //session=new SessionLabel(sessions);
                        }catch(IllegalArgumentException iae){
                             System.out.println(" --X Unable to parse the sesion address given");     
                        System.out.println(" - Open RTP session for "+session.port);
                        rtpmgrs[i]=(RTPManager) RTPManager.newInstance();               
                        rtpmgrs[i].addSessionListener(this);
                        rtpmgrs[i].addReceiveStreamListener(this);
                        ipAddr=InetAddress.getByName(session.addr);
                        if(ipAddr.isMulticastAddress()){
                             localAddr=new SessionAddress(ipAddr,session.port,session.ttl);
                             destAddr=new SessionAddress(ipAddr,session.port,session.ttl);
                        }else{
                             localAddr=new SessionAddress(InetAddress.getLocalHost(),session.port);     
                             destAddr=new SessionAddress(ipAddr,session.port);
                        rtpmgrs[i].initialize(localAddr);
                        BufferControl bc=(BufferControl)rtpmgrs[i].getControl("javax.media.control.BufferControl");
                        if(bc!=null)
                             bc.setBufferLength(600);
                        rtpmgrs[i].addTarget(destAddr);
              }catch(Exception ex){
                   System.out.println(" --X Cannot create RTP Session "+ex.getMessage());
              long currentTime=System.currentTimeMillis();
              long waitingDuration=10000;
              try{
                   synchronized(myDataSync){
                        while(!dataReceived && (System.currentTimeMillis() - currentTime < waitingDuration)){
                             if(!dataReceived){
                                  myDataSync.wait(1000);
              }catch(Exception ex){
                   System.out.println(" --X myDataSync interrupted...");
              if(!dataReceived){
                   System.out.println(" No RTP Stream Data is received.." );               
         public void destroy()
              for(int i=0;i<currentParticipant.size();i++){
                   //if(player!=null)
                        ((MyPlayList)currentParticipant.elementAt(i)).close();
              // Loop through the RTP Managers
              // -> Remove the stream listener
              // -> Remove the target address
              // -> Dispose the RTP Manager for garbage collection
              currentParticipant.removeAllElements();
              for(int i=0;i<rtpmgrs.length;i++){
                   if(rtpmgrs[i]!=null){
                        rtpmgrs[i].removeReceiveStreamListener(this);
                        rtpmgrs[i].removeTargets(" Closing session..");
                        rtpmgrs[i].dispose();
                        rtpmgrs[i]=null;
         MyPlayList find(Player pl){
              for(int i=0;i<currentParticipant.size();i++){
                   MyPlayList mpl=(MyPlayList)currentParticipant.elementAt(i);
                   if(mpl.clientPlay==pl)
                        return mpl;
              return null;
         MyPlayList find(ReceiveStream rs){
              for(int i=0;i<currentParticipant.size();i++){
                   MyPlayList mpl=(MyPlayList)currentParticipant.elementAt(i);
                   if(mpl.stream==rs)
                        return mpl;
              return null;
         *     ReceiveStream Listener function                    *
         public synchronized void update(ReceiveStreamEvent rse)
              RTPManager mgr=(RTPManager)rse.getSource();
              ReceiveStream stream=rse.getReceiveStream();
              Participant participant=rse.getParticipant();
              if(rse instanceof RemotePayloadChangeEvent){
                   System.out.println(" -- Received Payload Change Event..");
                   System.out.println(" Sorry, no payload change is allowed.");               
              }else if(rse instanceof NewReceiveStreamEvent){
                   try{
                        // Once the new stream is detected, create the datasource
                        stream=((NewReceiveStreamEvent)rse).getReceiveStream();
                        DataSource outputDS=stream.getDataSource();
                        // Get RTP Controller to find the format
                        RTPControl rtpctl=(RTPControl)outputDS.getControl("javax.media.rtp.RTPControl");
                        if(rtpctl!=null){
                             System.out.println(" -> Received new rtP stream: "+rtpctl.getFormat());
                        }else
                             System.out.println(" -> Received new RTP stream");
                        if(participant!=null){
                             System.out.println(" -> New stream received from: "+participant.getCNAME());
                        }else{
                             System.out.println(" -> New stream detected... ");
                        player=Manager.createPlayer(outputDS);
                        if(player==null)
                             return;
                        System.out.println(" - Player is created...");
                        player.addControllerListener(this);
                        player.realize();
                        // Helper class to identify the player and stream
                        MyPlayList mpl=new MyPlayList(player,stream);
                        // Add the helper class object to Vector
                        currentParticipant.addElement(mpl);
                        // Notify initializePlayer() that a new stream has arrived
                        synchronized(myDataSync){
                             dataReceived=true;
                             myDataSync.notifyAll();
                   }catch(Exception ex){
                        System.out.println(" --X NewReceiveStream Exception: "+ex.getMessage());
                        return;
              }else if(rse instanceof ByeEvent){
                   System.out.println(" - BYE packet received from "+participant.getCNAME());
                   MyPlayList mpls=find(stream);
                   if(player!=mpls){
                        mpls.close();
                        currentParticipant.removeElement(mpls);
                   if(mgr!=null){
                        mgr.removeReceiveStreamListener(this);
                        mgr.removeTargets(" Closing session..");
                        mgr.dispose();
                        mgr=null;
              }else if(rse instanceof StreamMappedEvent){
                   if(stream!=null && stream.getDataSource()!=null){
                        DataSource myds=stream.getDataSource();
                        RTPControl rtpctrl=(RTPControl)myds.getControl("javax.media.rtp.RTPControl");
                        System.out.println(" -> The previously unidentified stream ");
                        if(rtpctrl!=null)
                             System.out.println(" "+rtpctrl.getFormat());
                        System.out.println(" has been identified as sent by :"+participant.getCNAME());
         *           Session Listener
         public void update(SessionEvent sesevt)
              if(sesevt instanceof NewParticipantEvent){
                   Participant part=((NewParticipantEvent)sesevt).getParticipant();
                   System.out.println(" -> A new partcipant has joined :"+part.getCNAME());
         *     ControllerListener for Players          
         public synchronized void controllerUpdate(ControllerEvent ce)
              Player p=(Player)ce.getSource();
              if(p==null)
                   return;
              if(ce instanceof RealizeCompleteEvent){
                   MyPlayList mpls=find(p);
                   if(mpls!=null){
                        p.start();
                        if(p.getVisualComponent()!=null){
                             panel.add(player.getVisualComponent());
                             panel.validate();
              if(ce instanceof ControllerErrorEvent){
                   p.removeControllerListener(this);
                   MyPlayList mpls=find(p);
                   if(mpls!=null){
                        // Close the player
                        // Remove the player helper class object from the list
                        p.close();
                        currentParticipant.removeElement(mpls);
                   System.out.println("Receiver internal error: "+ce);
         class SessionLabel{
              public String addr=null;
              public int port;
              public int ttl;
              SessionLabel(String session) throws IllegalArgumentException
                   int off;
                   String portStr=null;
                   String ttlStr=null;
                   if(session!=null && session.length() >0){
                        while(session.length()>1 && session.charAt(0)=='/')
                             session=session.substring(1);
                        off=session.indexOf('/');
                        if(off==-1){
                             if(!session.equals(""))
                                  addr=session;
                        }else{
                             addr=session.substring(0,off);
                             session=session.substring(off+1);
                             off=session.indexOf('/');
                             if(off==-1){
                                  if(!session.equals(""))
                                       portStr=session;
                             }else{
                                  portStr=session.substring(0,off);
                                  session=session.substring(off+1);
                                  off=session.indexOf('/');
                                  if(off==-1){
                                       if(!session.equals(""))
                                            ttlStr=session;
                                  }else{
                                       ttlStr=session.substring(0,off);
                   if(addr==null)
                        throw new IllegalArgumentException();
                   if(portStr!=null)
                        try{
                             Integer ints=Integer.valueOf(portStr);
                             if(ints!=null)
                                  port=ints.intValue();
                        }catch(Throwable t){
                             System.out.println(" --X PortStr Error..");
                             throw new IllegalArgumentException();
                   }else
                        throw new IllegalArgumentException();
                   if(ttlStr!=null){
                   try{
                        Integer intsttl=Integer.valueOf(ttlStr);
                        if(intsttl!=null)
                             ttl=intsttl.intValue();
                   }catch(Throwable t){
                             System.out.println(" --X PortStr Error..");
                             throw new IllegalArgumentException();
         class MyPlayList{
              Player clientPlay;
              ReceiveStream stream;
              MyPlayList(Player p,ReceiveStream rs){
                   clientPlay=p;
                   stream=rs;
              public void close()
                   clientPlay.close();

  • DOM parsing In Applet (URgent)

    Is it possible to implement DOM parsing in Applet?
    I am getting classnotfoundException .
    I am giving the code below. pl read the code.
    Applet.(parserapplet.java)
    =========================
    import java.io.*;
    import java.awt.*;
    import java.net.*;
    import java.util.*;
    import java.applet.*;
    import com.security.*;
    // for DOM parsing ....
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import org.w3c.dom.Document;
    import org.w3c.dom.DOMException;
    public class parserapplet extends Applet
    public void init()
    public void start()
    try
    if (Class.forName("com.ms.security.PolicyEngine") != null)
    {  // required for IE
         PolicyEngine.assertPermission( PermissionID.SYSTEM );
    catch (Throwable cnfe)
         System.out.println("Policy Engine Exception: " + cnfe);
    try
         String str = "<?xml
    version=\"1.0\"?><html><body></body></html>";
         ByteArrayInputStream bis = new
    ByteArrayInputStream(str.getBytes());
         System.out.println("After creating input stream");
         BufferedInputStream bufIn     = new BufferedInputStream(new
    DataInputStream(bis));
         parseXMLMessage     (bufIn);
    catch(Exception e){}
    // Actual DOM parsing goes here.....
    public void parseXMLMessage(InputStream xmlMessage)
    Document document      = null;
         DocumentBuilder documentBuilder           = null;
         DocumentBuilderFactory documentBuilderFactory     = null;
         try
         documentBuilderFactory = DocumentBuilderFactory.newInstance();
         documentBuilder     = documentBuilderFactory.newDocumentBuilder();
         document     = documentBuilder.parse(xmlMessage);
         System.out.println("Document node: " + document);
         catch(FactoryConfigurationError fce)
         System.out.println("Exception Factory configuration error " + fce);
         catch(ParserConfigurationException pce)
         System.out.println("Exception Parser configuration Exception " pce);
         catch(SAXException saxe)
         System.out.println("Exception SAX error " + saxe);
         catch(Exception e)
         System.out.println("Exception " + e);
    Html code:
    =========
    <html>
    <body>
    <APPLET code="parserapplet.class" archive = "xalan.jar" width=0
    height=0
    MAYSCRIPT>
    <param name=cabbase value=MyApplet.cab>
    </APPLET>
    </body>
    </html>
    I have signed the Applet using signcode utility and i have put the
    parserapplet.class in the MyApplet cab file and signed it. On invoking
    the html file, it request for permission, and after clicking yes, the
    applet loads.Fine.
    No problem upto this stage.
    But after loading of the applet the following exception is thrown in
    Javaconsole.
    Exception:
    =========
    com.ms.security.SecurityExceptionEx[Host]: cannot access file
    C:\WINNT\Java\lib\jaxp.properties
    at com/ms/security/permissions/FileIOPermission.check
    at com/ms/security/PolicyEngine.deepCheck
    at com/ms/security/PolicyEngine.checkPermission
    at com/ms/security/StandardSecurityManager.chk
    at com/ms/security/StandardSecurityManager.checkRead
    at java/io/File.exists
    at javax/xml/parsers/DocumentBuilderFactory.findFactory
    at javax/xml/parsers/DocumentBuilderFactory.newInstance
    at parserapplet.parseXMLMessage
    at parserapplet.init
    at com/ms/applet/AppletPanel.securedCall0
    at com/ms/applet/AppletPanel.securedCall
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.run
    at java/lang/Thread.run
    javax.xml.parsers.FactoryConfigurationError:
    java.lang.ClassNotFoundException:
    org/apache/crimson/jaxp/DocumentBuilderFactoryImpl
    at javax/xml/parsers/DocumentBuilderFactory.newInstance
    at parserapplet.parseXMLMessage
    at parserapplet.init
    at com/ms/applet/AppletPanel.securedCall0
    at com/ms/applet/AppletPanel.securedCall
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.run
    at java/lang/Thread.run
    I dont know which .jar file to archive (i tried xalan,crimson, jaxp
    but which of no use). I was surprised why the security Exception is
    thrown , when parsing.
    I have not accessed the System files!( but it searches for
    jaxp.properties file!). I think the jar file is not downloaded. How to
    verify that it is downloaded in applet?
    The above code is only for sample.
    If anybody who knows how to correct it please mail me at:
    "[email protected]" with corrected code. I want this very
    urgently.
    Help meeeeeeeeeeeeeeeeeeee!!!!!
    Prasanna.

    Have you found the answer to this problem? I am having a similar problem when running the parser in an ActiveX Bean.
    THanks

Maybe you are looking for

  • Can i put a single Itunes directory in the Shared File folder of a computer

    Can i put a single Itunes directory/song list in the Shared Folder of my computer and everyone in the house utilize the one account? This way we keep all the available music on one computer and accessible to everyone.

  • FI12 (house bank) problem

    Dear Experts, In FI12, on each house banks, there was one g/l account. Is there any relationship between gl account in FI12 and Account in customer and vendor? From which t code in vendor and customer area in SAP that I could find the same GL account

  • Restore System from Q: Lenovo_Recovery Drive

    Hello Everyone! If you've installed another operating system over Windows 7 and want the stock configuration back, its possible to recover the system using the contents of the Q: lenovo_Recovery Drive, another computer, a Windows 7 installation disk

  • Usage of reverse key index

    Hi, Any body can explain the usage of reverse key index. Thanks and regards,

  • JCA AqAdapter on OSB - How to rollback on failure?

    Hi, I have an AqAdapter (JCA resource) on OSB. So, I generated a ProxyService that calls a BPEL BusinessService. If the BusinessService isn't available or some fault occurs in it, how can I get a rollback on AQ? Example: 1. JCA gets a row from AQ and