Exception in html parser under Linux
Hi all,
Following code is copied from Tech Tip 23Sep1999. I have compiled it and run it under Win98. It works fine for any uri. However, when I try to run it under Linux, it throws exceptions. I noticed that some web site can be parsered with the program in Linux but some can't. I wonder the different between those platforms. Anyone can tell me how to make the program works under Linux.
Rgds,
unplug
configuration
RedHat 7.1
JDK1.3.1
Failed: java GetLinks http://java.sun.com
Worked: java GetLinks http://www.apache.org
--begining of code
import java.io.*;
import java.net.*;
import javax.swing.text.*;
import javax.swing.text.html.*;
class GetLinks {
public static void main(String[] args) {
EditorKit kit = new HTMLEditorKit();
Document doc = kit.createDefaultDocument();
// The Document class does not yet
// handle charset's properly.
doc.putProperty("IgnoreCharsetDirective",
Boolean.TRUE);
try {
// Create a reader on the HTML content.
Reader rd = getReader(args[0]);
// Parse the HTML.
kit.read(rd, doc, 0);
// Iterate through the elements
// of the HTML document.
ElementIterator it = new ElementIterator(doc);
javax.swing.text.Element elem;
while ((elem = it.next()) != null) {
SimpleAttributeSet s = (SimpleAttributeSet)
elem.getAttributes().getAttribute(HTML.Tag.A);
if (s != null) {
System.out.println(
s.getAttribute(HTML.Attribute.HREF));
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
// Returns a reader on the HTML data. If 'uri' begins
// with "http:", it's treated as a URL; otherwise,
// it's assumed to be a local filename.
static Reader getReader(String uri)
throws IOException {
if (uri.startsWith("http:")) {
// Retrieve from Internet.
URLConnection conn=
new URL(uri).openConnection();
return new
InputStreamReader(conn.getInputStream());
} else {
// Retrieve from file.
return new FileReader(uri);
--End of code
--Exception in Linux
Exception in thread "main" java.lang.NoClassDefFoundError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:120)
at java.awt.Toolkit$2.run(Toolkit.java:512)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:503)
at javax.swing.text.html.CSS.getValidFontNameMapping(CSS.java:932)
at javax.swing.text.html.CSS$FontFamily.parseCssValue(CSS.java:1789)
at javax.swing.text.html.CSS.getInternalCSSValue(CSS.java:531)
at javax.swing.text.html.CSS.addInternalCSSValue(CSS.java:516)
at javax.swing.text.html.StyleSheet.addCSSAttribute(StyleSheet.java:436)
at javax.swing.text.html.HTMLDocument$HTMLReader$ConvertAction.start(HTM
LDocument.java:2536)
at javax.swing.text.html.HTMLDocument$HTMLReader.handleStartTag(HTMLDocu
ment.java:1992)
at javax.swing.text.html.parser.DocumentParser.handleStartTag(DocumentPa
rser.java:145)
at javax.swing.text.html.parser.Parser.startTag(Parser.java:333)
at javax.swing.text.html.parser.Parser.parseTag(Parser.java:1786)
at javax.swing.text.html.parser.Parser.parseContent(Parser.java:1821)
at javax.swing.text.html.parser.Parser.parse(Parser.java:1980)
at javax.swing.text.html.parser.DocumentParser.parse(DocumentParser.java
:109)
at javax.swing.text.html.parser.ParserDelegator.parse(ParserDelegator.ja
va:74)
at javax.swing.text.html.HTMLEditorKit.read(HTMLEditorKit.java:239)
at GetLinks.main(GetLinks.java:23)
Support for CSS and clearly defined.Also Dictionary getDocumentProperties() is not properly exaplained meaning it doesnt give methods to get all the properties a HTML document can have.
Similar Messages
-
Workshop under Linux: HTML/JSP visual edtiting?
I guess under win32 they use IE control. How about mozilla engine under linux?
In case is not available at least it should be visible
in release/requirements notes.
I hoped,at least in SP4 after so many months/years,
something to appear! But I guess SPs are just are
just Sanitizing and Purification ;-)
Dan.augustobacellar,
The Visual Editor in JDeveloper 11 functions in much the same way it did in 10g. We use a page flow method of layout, not absolute positioning. This adheres to the container style model of layout provided by the JSF and allows JDeveloper to support Visual rendering for an array of component sets. Both the absolute positioning Visual Editors relay on one specific proprietary component set and do not support this style of visual development for other components. Thus, to adhere to our mantra of choice we chose a more robust approach.
Regards,
Ric -
Unknown exception during NsSAX2Reader parse
Hello!
I'm using java API for Berkeley DB XML 2.4.13 under Windows XP SP2.
I have the following peace of code:
documentConfig = new XmlDocumentConfig();
XmlResults results = xmlContainer.getAllDocuments(documentConfig);
while(results.hasNext()) {
XmlDocument doc = results.next().asDocument();
After the line "XmlDocument doc = results.next().asDocument()" I get an exception:
com.sleepycat.dbxml.XmlException: Error: Unknown exception during NsSAX2Reader parse File: \dbxml-2.4.13\dbxml\src\dbxml\nodeStore\NsSAX2Reader.cpp Line: 366, errcode = INTERNAL_ERROR
at com.sleepycat.dbxml.dbxml_javaJNI.XmlResults_nextInternal(Native Method)
at com.sleepycat.dbxml.XmlResults.nextInternal(XmlResults.java:162)
at com.sleepycat.dbxml.XmlResults.next(XmlResults.java:47)
.... (exceptions in my code)
Does anybody know how to figure out what is the reason of this error?
Additional information:
I added documents to the container via C++ API
The container has WholeDoc type
Thanks in advance
Vyacheslav<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE omdoc PUBLIC "-//OMDoc//DTD OMDoc V1.2//EN"
"../../dtd/omdoc.dtd" []>
<omdoc xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.mathweb.org/omdoc"
xml:id="alg1-omdoc">
<metadata>
<dc:title>The OpenMath Content Dictionary alg1.ocd in OMDoc form</dc:title>
<dc:creator role="trl">Michael Kohlhase</dc:creator>
<dc:creator role="ant">The OpenMath Society</dc:creator>
<dc:date> 2001-03-12T00:00:00</dc:date>
<dc:source>Derived from the OpenMath CD http://www.openmath.org/cd/alg1.ocd.</dc:source>
<dc:type>Text</dc:type>
<dc:format>application/omdoc+xml</dc:format>
<dc:rights>Copyright (c) 2000-2002 Michael Kohlhase;
This OMDoc content dictionary is released under the OpenMath license:
http://monet.nag.co.uk/openmath/cdfiles/license.html
</dc:rights>
<dc:description>
A CD of basic algebraic concepts
At present this CD only holds definitions of zero and one. They are
deliberately defined here without specifying any particular structure
(e.g. a group) to which they correspond.
</dc:description>
</metadata>
<theory xml:id="alg1">
<imports xml:id="alg1-imports-quant1" from="quant1.omdoc#quant1"/>
<imports xml:id="alg1-imports-relation1" from="relation1.omdoc#relation1"/>
<imports xml:id="alg1-imports-arith1" from="arith1.omdoc#arith1"/>
<imports xml:id="alg1-imports-logic1" from="logic1.omdoc#logic1"/>
<imports xml:id="alg1-imports-set1" from="set1.omdoc#set1"/>
<imports xml:id="alg1-imports-setname1" from="setname1.omdoc#setname1"/>
<symbol name="zero" xml:id="zero">
<metadata>
<dc:description>This symbol represents the additive identity element.</dc:description><dc:subject>zero</dc:subject></metadata>
<type system="sts.omdoc#sts">
<OMOBJ xmlns="http://www.openmath.org/OpenMath"><OMV name="AbelianMonoid"/></OMOBJ>
</type>
</symbol>
<presentation xml:id="pr-zero" for="#zero">
<use format="default">0</use>
<use format="cmml" element="zero"/>
</presentation>
<assertion xml:id="zero-prop-1" type="lemma">
<CMP> for all a | a + 0 = a </CMP>
<FMP>
<OMOBJ xmlns="http://www.openmath.org/OpenMath">
<OMBIND>
<OMS cd="quant1" name="forall"/>
<OMBVAR>
<OMV name="a"/>
</OMBVAR>
<OMA>
<OMS cd="relation1" name="eq"/>
<OMA>
<OMS cd="arith1" name="plus"/>
<OMV name="a"/>
<OMS cd="alg1" name="zero"/>
</OMA>
<OMV name="a"/>
</OMA>
</OMBIND>
</OMOBJ>
</FMP>
</assertion>
<assertion xml:id="zero-prop-3" type="lemma">
<CMP> for all a | 0 * a = 0 </CMP>
<FMP>
<OMOBJ xmlns="http://www.openmath.org/OpenMath">
<OMBIND>
<OMS cd="quant1" name="forall"/>
<OMBVAR>
<OMV name="a"/>
</OMBVAR>
<OMA>
<OMS cd="relation1" name="eq"/>
<OMA>
<OMS cd="arith1" name="times"/>
<OMS cd="alg1" name="zero"/>
<OMV name="a"/>
</OMA>
<OMS cd="alg1" name="zero"/>
</OMA>
</OMBIND>
</OMOBJ>
</FMP>
</assertion>
<assertion xml:id="zero-prop-5" type="lemma">
<CMP>The zero of the integers is 0</CMP>
<FMP>
<OMOBJ xmlns="http://www.openmath.org/OpenMath">
<OMBIND>
<OMS cd="quant1" name="forall"/>
<OMBVAR>
<OMV name="x"/>
</OMBVAR>
<OMA>
<OMS cd="logic1" name="implies"/>
<OMA>
<OMS cd="logic1" name="and"/>
<OMA>
<OMS cd="set1" name="in"/>
<OMV name="x"/>
<OMS cd="setname1" name="Z"/>
</OMA>
<OMA>
<OMS cd="relation1" name="eq"/>
<OMV name="x"/>
<OMS cd="alg1" name="zero"/>
</OMA>
</OMA>
<OMA>
<OMS cd="relation1" name="eq"/>
<OMV name="x"/>
<OMI>0</OMI>
</OMA>
</OMA>
</OMBIND>
</OMOBJ>
</FMP>
</assertion>
<symbol name="one" xml:id="one">
<metadata>
<dc:description>This symbol represents the multiplicative identity element.</dc:description><dc:subject>one</dc:subject></metadata>
<type system="sts.omdoc#sts">
<OMOBJ xmlns="http://www.openmath.org/OpenMath">
<OMV name="Monoid"/>
</OMOBJ>
</type>
</symbol>
<presentation xml:id="pr-one" for="#one">
<use format="default">1</use>
<use format="cmml" element="one"/>
</presentation>
<assertion xml:id="one-prop-1" type="lemma">
<CMP> for all a | 1 * a = a </CMP>
<FMP>
<OMOBJ xmlns="http://www.openmath.org/OpenMath">
<OMBIND>
<OMS cd="quant1" name="forall"/>
<OMBVAR>
<OMV name="a"/>
</OMBVAR>
<OMA>
<OMS cd="relation1" name="eq"/>
<OMA>
<OMS cd="arith1" name="times"/>
<OMS cd="alg1" name="one"/>
<OMV name="a"/>
</OMA>
<OMV name="a"/>
</OMA>
</OMBIND>
</OMOBJ>
</FMP>
</assertion>
<assertion xml:id="one-prop-3" type="lemma">
<CMP> for all a | a * 1 = a </CMP>
<FMP>
<OMOBJ xmlns="http://www.openmath.org/OpenMath">
<OMBIND>
<OMS cd="quant1" name="forall"/>
<OMBVAR>
<OMV name="a"/>
</OMBVAR>
<OMA>
<OMS cd="relation1" name="eq"/>
<OMA>
<OMS cd="arith1" name="times"/>
<OMV name="a"/>
<OMS cd="alg1" name="one"/>
</OMA>
<OMV name="a"/>
</OMA>
</OMBIND>
</OMOBJ>
</FMP>
</assertion>
<assertion xml:id="one-prop-5" type="lemma">
<CMP>The one of the integers is 1</CMP>
<FMP>
<OMOBJ xmlns="http://www.openmath.org/OpenMath">
<OMBIND>
<OMS cd="quant1" name="forall"/>
<OMBVAR>
<OMV name="x"/>
</OMBVAR>
<OMA>
<OMS cd="logic1" name="implies"/>
<OMA>
<OMS cd="logic1" name="and"/>
<OMA>
<OMS cd="set1" name="in"/>
<OMV name="x"/>
<OMS cd="setname1" name="Z"/>
</OMA>
<OMA>
<OMS cd="relation1" name="eq"/>
<OMV name="x"/>
<OMS cd="alg1" name="one"/>
</OMA>
</OMA>
<OMA>
<OMS cd="relation1" name="eq"/>
<OMV name="x"/>
<OMI>1</OMI>
</OMA>
</OMA>
</OMBIND>
</OMOBJ>
</FMP>
</assertion>
</theory>
</omdoc> -
JMF code working under linux but not windows XP
Hello everyone,
I'm currently working on a nice cross-platform project involving sound producing. I decided to take a look at JMF and test it a bit to know if its features can suit me. I tried to make it works under windows, using a very simple sample of code. The system seems to play the sound as some console output detects the start and the end, but all i hear is a very short noise ( 1/2second ) like a "CLIK" and nothing else. I tested the code under linux, using the same computer and it works just fine, playing the same wave nicely and entirely.
some info:
-i used the cross platform JMF, no performance pack ( i tried it , but still no result )
-the code just opens a file dialog and plays the selected file
-the selected file was always a very simple .wav
-i did not use system classpath variables because i don't like it, i rather use local classpath ( which works fine too, no doubt about it )
-i tested this little soft on 2 other computer using windows XP, and still got the same result.
Please, have you got an idea about what's going on ?
Thanks a lot for any answer!
Maxime - Paris . France
Code Sample:
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import javax.media.*;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
public class JMFSound extends Object implements ControllerListener {
File soundFile;
JDialog playingDialog;
public static void main (String[] args) {
JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(null);
File f = chooser.getSelectedFile();
try {
JMFSound s = new JMFSound (f);
} catch (Exception e) {
e.printStackTrace();
public JMFSound (File f) throws NoPlayerException, CannotRealizeException, MalformedURLException, IOException {
soundFile = f;
// prepare a dialog to display while playing
JOptionPane pane = new JOptionPane ("Playing " + f.getName(), JOptionPane.PLAIN_MESSAGE);
playingDialog = pane.createDialog (null, "JMF Sound");
playingDialog.pack();
// get a player
MediaLocator mediaLocator = new MediaLocator(soundFile.toURL());
Player player = Manager.createRealizedPlayer (mediaLocator);
player.addControllerListener (this);
player.prefetch();
player.start();
playingDialog.setVisible(true);
// ControllerListener implementation
public void controllerUpdate (ControllerEvent e) {
System.out.println (e.getClass().getName());
if (e instanceof EndOfMediaEvent) {
playingDialog.setVisible(false);
System.exit (0);
Message was edited by:
Monsieur_MaxHello everyone,
I'm currently working on a nice cross-platform project involving sound producing. I decided to take a look at JMF and test it a bit to know if its features can suit me. I tried to make it works under windows, using a very simple sample of code. The system seems to play the sound as some console output detects the start and the end, but all i hear is a very short noise ( 1/2second ) like a "CLIK" and nothing else. I tested the code under linux, using the same computer and it works just fine, playing the same wave nicely and entirely.
some info:
-i used the cross platform JMF, no performance pack ( i tried it , but still no result )
-the code just opens a file dialog and plays the selected file
-the selected file was always a very simple .wav
-i did not use system classpath variables because i don't like it, i rather use local classpath ( which works fine too, no doubt about it )
-i tested this little soft on 2 other computer using windows XP, and still got the same result.
Please, have you got an idea about what's going on ?
Thanks a lot for any answer!
Maxime - Paris . France
Code Sample:
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import javax.media.*;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
public class JMFSound extends Object implements ControllerListener {
File soundFile;
JDialog playingDialog;
public static void main (String[] args) {
JFileChooser chooser = new JFileChooser();
chooser.showOpenDialog(null);
File f = chooser.getSelectedFile();
try {
JMFSound s = new JMFSound (f);
} catch (Exception e) {
e.printStackTrace();
public JMFSound (File f) throws NoPlayerException, CannotRealizeException, MalformedURLException, IOException {
soundFile = f;
// prepare a dialog to display while playing
JOptionPane pane = new JOptionPane ("Playing " + f.getName(), JOptionPane.PLAIN_MESSAGE);
playingDialog = pane.createDialog (null, "JMF Sound");
playingDialog.pack();
// get a player
MediaLocator mediaLocator = new MediaLocator(soundFile.toURL());
Player player = Manager.createRealizedPlayer (mediaLocator);
player.addControllerListener (this);
player.prefetch();
player.start();
playingDialog.setVisible(true);
// ControllerListener implementation
public void controllerUpdate (ControllerEvent e) {
System.out.println (e.getClass().getName());
if (e instanceof EndOfMediaEvent) {
playingDialog.setVisible(false);
System.exit (0);
Message was edited by:
Monsieur_Max -
Cannot install JMF under Linux Mandrake 10
I simply cannot install JMF under the Mandrake 10 Official Linux distribution. I downloaded the jmf-2_1_1e-linux-i586.bin file and tried to execute it as root. It unzipped some files then showed me an error message about AWT and GTK+. I found a hack consisting of modifying the .bin file to have the PATH variable point to SUN JDK, the error does not show up, but the installation still does not work. In fact, the installation works, but the Diagnostics applet keeps telling me than class files are not present. My Mozilla 1.6 Java plugin is working and displaying the applet. My JMF lib directory does not contain sound.jar, such jmf.jar. I set the CLASSPATH and LD_LIBRARY_PATH according to the readme.html file. I would like to know if it is a compatibility problem with Mandrake 10, the 2.6 kernel or if JMF just DO NO work under Linux. In the latter case, JMF is a violation to the Java portability philosophy and I would never use it on my own initiative, just if I were asked to.
After the files are unzipped, I have the following warning and error messages.
Warning:
Name: HorScrollBar
Class: XmScrollBar
The specified scrollbar value is greater than the maximum
scrollbar value minus the scrollbar slider size.
JavaSound Capture Supported = true
JavaSoundAuto: Committed ok
java.lang.Error: Can't open video card 0
java.lang.Error: Can't open video card 1
java.lang.Error: Can't open video card 2
java.lang.Error: Can't open video card 3
java.lang.Error: Can't open video card 4
java.lang.Error: Can't open video card 5
java.lang.Error: Can't open video card 6
java.lang.Error: Can't open video card 7
java.lang.Error: Can't open video card 8
java.lang.Error: Can't open video card 9
Done.
Even if I do not have a working video capture card (I have an ATI All-in-Wonder 128 but it is not working under 2.6 kernel), JMF should work because some people do not have a video capture card. I also tried with the cross-platform ZIP file, but this one does not contain sound.jar either and the Diagnostics applet keeps complaining about missing class files. I tried to search on the Web for solutions to this problem or for a way to change the CLASSPATH used by the Mozilla Java plug-in (if it uses a different CLASSPATH than the one from the environment variable), but nothing, nothing. Is there a distribution from which JMF would work better than Mandrake 10? Or can JMF work only under Microsoft Windows or Sun Solaris? I also tried Blackdown, but a README file directed me to the Sun's page, nothing to download here about JMF.well, your not the only one.
I have it working in Debian, and JDS.(JMF is setup automatically in JDS).(2.6.6 kernel)
I looked at the installation structure of JDS, and was able to duplicate what they did for Debian.
Maybe it will work for Mandrake two??
ok, all you have to do is copy or create soft links from your Mozilla directory, just like you did with the java plugin, and link to all the *.so files in JMF-2.1.1e/lib directory.
Should work.
I also read that not haveing the native files only matters if you are doing Capture. not play.
to get your ATI All-in-Wonder 128 to work, make sure you install the correct driver, and have it working under linux, then try it in JMSTUDIO -
Failed to install enterprise manager under linux
When I installed Oracle 10g(10.2.0.1) under linux, I got an error when running
/ora01/db/oracle/product/10.2.0.1/bin/emca within oracle universal installer.
The emConfig.log file shows such error:
oracle.sysman.emcp.exception.EMConfigException: Invalid value null for parameter PORT
at oracle.sysman.emcp.ParamsManager.checkParam(ParamsManager.java:2630)
at oracle.sysman.emcp.EMDBPreConfig.checkConfigParams(EMDBPreConfig.java:1285)
at oracle.sysman.emcp.EMDBPreConfig.checkParameters(EMDBPreConfig.java:1060)
at oracle.sysman.emcp.EMDBPreConfig.invoke(EMDBPreConfig.java:174)
at oracle.sysman.emcp.EMDBPreConfig.invoke(EMDBPreConfig.java:160)
at oracle.sysman.emcp.EMConfig.perform(EMConfig.java:141)
at oracle.sysman.assistants.util.em.EMConfiguration.run(EMConfiguration.java:426)
at java.lang.Thread.run(Thread.java:534)
So I have to run emca after the oracle installation. I am new to this tool. I modified both tnsnames.ora and listener.ora file to set port to 1521. And then I run emca -config all db,
but now I cannot pass "entering the password for SYS user" (I already set SYS user's password to oracle, and it works when using sqlplus.) .
I am totally confused. What should I run emca to set up the enterprise manager's website? Now I can use localhost:5560/isqlplus and localhost:5560/isqlplus/dba.
Many thanks!!I just run emca as oracle instead of root, then the password got passed, but I got new errors:
Aug 30, 2007 5:59:59 PM oracle.sysman.emcp.EMConfig perform
SEVERE: Failed to allocate port(s) in the specified range(s) for the following process(es): JMS [5540-5559],RMI [5520-5539],Database Control [5500-5519],EM Agent [3938] | [1830-1849]
What should I do? Is running emca -config all db necessary to get enterprise manager installed? -
How to output executable Bin file under linux from java
Hi
im beginner in java under linux and i want to out put my java programs to be bin files that can run
if this not possilble
how to run the output jar files with just double click ?
does i have to run sh file that do the hob how?
thanks in advance.say your main method (application's entry point) is located in a class com.my.Class,
then first you create a text file (say, manifest.txt) that contains this line:
Main-Class: com.my.Class
[/code}
and then you append this to the jar's manifest as such:
jar cfm yourjarfile.jar manifest.txt [additional files you might want to add]
for more info,
http://java.sun.com/docs/books/tutorial/deployment/jar/manifestindex.html -
Don't understand error message from HTML parser?
I've written a simple test program to parse a simple html file.
Everything works fine accept for the <img src="test.gif"> tag.
It understands the img tag and the handleSimpleTag gets called.
I can even pick out the src attribute. But I get a very strange error message.
When I run the test program below on the test.html file (also below) I get the following output:
handleError(134) = req.att srcimg?
What does "req.att srcimg?" mean?!?!?
/John
This is my test program:
import javax.swing.text.html.*;
import javax.swing.text.*;
import javax.swing.text.html.parser.*;
import java.io.*;
public class htmltest extends HTMLEditorKit.ParserCallback
public htmltest()
super();
public void handleError(String errorMsg, int pos)
System.err.println("handleError("+pos+") = " + errorMsg);
static public void main (String[] argv) throws Exception
Reader reader = new FileReader("test.html");
new ParserDelegator().parse(reader, new htmltest(), false);
This is the "test.html" file
<html>
<head>
</head>
<body>
This is a plain text.<br>
This is <b>bold</b> and this is <i>itallic</i>!<br>
<img src="test.gif">
"This >is also a plain test text."<br>
</body>
</html>
----------------------------------------------------------------------The handleError() method is not well documented any more than whole javax.swing.text.html package and its design structure. You can ignore the behavior of the method if other result of the parser and your HTML file are proper.
-
Attempting to use HTML parser - getAttribute() not preforming as expected.
How am I mis-using getAttribute()?
I am expecting (String)a.getAttribute((String)"name") to give me a value other than null in the below example. What am I doing wrong?
The HTML test source (missing headers/body so yes its not proper)
<input name="unit_1" size=5 maxsize=5 value="hr">
<input name="qty_1" size=5 value=4>
<input name="unit_1" size=5 maxsize=5 value="hr">
<input name="partnumber_1" size=10 value="Java Work">
<input name="description_1" size=50 value="Slip shod work at outragous prices">
<input name="sellprice_1" size=9 value=185.00>
<input name="discount_1" size=3 value=>
What I'd like to see is this:
About to parse test
Parsing error: invalid.tagattmaxsizeinput? at 39
Tag start(<html>, 1 attrs)
Tag start(<head>, 1 attrs)
Tag end(</head>)
Tag start(<body>, 1 attrs)
Tag(<input>, 4 attrs)
found input
unit_1
hr
Tag(<input>, 3 attrs)
found input
qty_1
4
Rather than this:
About to parse test
Parsing error: invalid.tagattmaxsizeinput? at 39
Tag start(<html>, 1 attrs)
Tag start(<head>, 1 attrs)
Tag end(</head>)
Tag start(<body>, 1 attrs)
Tag(<input>, 4 attrs)
found input
null
null
Tag(<input>, 3 attrs)
found input
null
null
The code that reads the HTML and give the output looks like this:
import java.io.*;
import java.net.*;
import javax.swing.text.*;
import javax.swing.text.html.*;
import javax.swing.text.html.parser.*;
* This small demo program shows how to use the
* HTMLEditorKit.Parser and its implementing class
* ParserDelegator in the Swing system.
class DataSaved {
String InputName;
String InputValue;
boolean IsHidden;
public class HtmlParseDemo {
public static void main(String [] args) {
DataSaved DataSet[];
Reader r;
if (args.length == 0) {
System.err.println("Usage: java HTMLParseDemo [url | file]");
System.exit(0);
String spec = args[0];
try {
if (spec.indexOf("://") > 0) {
URL u = new URL(spec);
Object content = u.getContent();
if (content instanceof InputStream) {
r = new InputStreamReader((InputStream)content);
else if (content instanceof Reader) {
r = (Reader)content;
else {
throw new Exception("Bad URL content type.");
else {
r = new FileReader(spec);
HTMLEditorKit.Parser parser;
System.out.println("About to parse " + spec);
parser = new ParserDelegator();
parser.parse(r, new HTMLParseLister(), true);
r.close();
catch (Exception e) {
System.err.println("Error: " + e);
e.printStackTrace(System.err);
* HTML parsing proceeds by calling a callback for
* each and every piece of the HTML document. This
* simple callback class simply prints an indented
* structural listing of the HTML data.
class HTMLParseLister extends HTMLEditorKit.ParserCallback
int indentSize = 0;
protected void indent() {
indentSize += 3;
protected void unIndent() {
indentSize -= 3; if (indentSize < 0) indentSize = 0;
protected void pIndent() {
for(int i = 0; i < indentSize; i++) System.out.print(" ");
public void handleText(char[] data, int pos) {
pIndent();
System.out.println("Text(" + data.length + " chars)");
public void handleComment(char[] data, int pos) {
pIndent();
System.out.println("Comment(" + data.length + " chars)");
public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) {
pIndent();
System.out.println("Tag start(<" + t.toString() + ">, " +
a.getAttributeCount() + " attrs)");
indent();
public void handleEndTag(HTML.Tag t, int pos) {
unIndent();
pIndent();
System.out.println("Tag end(</" + t.toString() + ">)");
public void handleSimpleTag(HTML.Tag t, MutableAttributeSet a, int pos) {
String name;
String value;
boolean hidden;
pIndent();
System.out.println("Tag(<" + t.toString() + ">, " +
a.getAttributeCount() + " attrs)");
if( t==HTML.Tag.INPUT) {
System.out.println("found input");
name = (String)a.getAttribute((String)"name");
value = (String)a.getAttribute((String)"value");
System.out.println(name);
System.out.println(value);
public void handleError(String errorMsg, int pos){
System.out.println("Parsing error: " + errorMsg + " at " + pos);System.out.println( a.getAttribute(HTML.Attribute.NAME) );
-
Errors occurs when localizing an Struts webapps in Tomcat5.0 under Linux.
I have an Struts webapps,which was deployed correctly and ran well in my Tomat5.0 under win2K.
Then i copied the webapps to the Tomcat5.0_HOME/webapps/ under Linux.
Then i copied all the struts *.jar files to the Tomcat5.0_HOME/common/lib.
With the web.xml and struts-config.xml configed well,i restarted the Tomcat and then found my webapps existing in the Tomcat5.0 by browsing the manager page of the container,and i found that my webapps run well.(The start hyper-link of my webapps in the manager page in not underline,this means my webapps have just run well and the web.xml is correct).
Then i access my login.jsp which runs well at my Win2k platform.
But errors occured at that time:
The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Cannot find ActionMappings or ActionFormBeans collection
What's worong?up
-
Hello.
I looked through the older web sites of IBM regarding the usage of JCOP tools under Linux.
I am interested in following questions:
1. Is there any separate distributon version of JCOP tools for Linux?
2. Can sample JCOP tools 3.1.2 plugin (for Windows) be used under Linux. What has to be modified? Also what additional tools have to be installed an used for communication with real cards through PC/SC readers.
3. Is JCOP simulation option available under Linux?
I'll appreciate any help.
Best regards,
newbienewbie2007 wrote:Hello.
I looked through the older web sites of IBM regarding the usage of JCOP tools under Linux.
I am interested in following questions:
1. Is there any separate distributon version of JCOP tools for Linux?
2. Can sample JCOP tools 3.1.2 plugin (for Windows) be used under Linux. What has to be modified? Also what additional tools have to be installed an used for communication with real cards through PC/SC readers.
3. Is JCOP simulation option available under Linux?
I'll appreciate any help.
Best regards,
newbieEverything should work, except for the target pack and the non-existent Linux Pegoda driver.1. The is no seperate Linux distribution. You just need a Linux distribution for Eclipse.JCOP Tools plugin should work under Linux, except for the target pack and the non-existent Pegoda driver for Linux.1. There is no seperate Linux distribution. You just need the Linux distribution for Eclipse.
2. Prior to JCOP Tools 3.1.2 the last time something was mentioned about Linux was in the release notes of 3.1.1b . In version 3.2.0 IBM added a linux_support page to the JCOP Tools user guide (see release notes and linux_support page below).
3. There shouldn't be any problems with the generic simulation. The target pack runs only with Windows though.
h1. Release Notes
h2. Version
JCOP Tools 3.1.1.b (Bärlach)
h2. What's new?
h3. 3.1.1.b
<ul><li>New simulation (fixed static obj/arr bug, fixed instance field token bug).</li>
<li>Applet privileges can now be specified in the launch configuration dialog.</li>
<li>The "exportmap" feature is now available.</li>
<li>The JCOP Performance Test Demo ("JCOP Factor") is now included.</li>
<li>Minor bug fixes.</li>
</ul>
h2. Known problems
<ul><li>Simulations do not run (Linux, MacOS X)
The Eclipse update manager does not set the execute permission bits for the simulations. You need to manually <code>chmod 755</code> those files in ECLIPSE/plugins/com.ibm.bluez.jcop.eclipse_3.1.1.x/simuls/
</li>
<li>PC/SC Support (Linux)
JCOP Tools only works with pcsc-lite 1.2.0.
</li>
</ul>
h2. Frequently Asked Questions
Please refer to the online FAQ at http://www.zurich.ibm.com/jcop/download/eclipse/faq/.
h2. Bug Reports
Please send bug reports to [email protected]. Make sure you include the following:
<ul><li>Problem description</li>
<li>Steps to reproduce</li>
<li>Eclipse version and build number (Help > About)</li>
<li>JCOP Tools version (Help > About; click on BlueZ icon)</li>
</ul>
h2. Using JCOP Tools with Linux (>= 3.2.0)
h3. ___
Overview
The current JCOP Tools release now also offer a version for the popular Linux
operating system. Both the Windows and Linux verson provide more or less the same
functionality, and JCOP application development can thus fully succeed on Linux systems.
Nevertheless, installation of the JCOP Tools differ between Windows and Linux
where the Linux version does not provide a simple installer as in case of Windows.
Additionally, the Linux version expects a properly setup Muscle PCSC installation
as soon as you want to use them together with physical, real cards. As Muscle
PCSC is still not shipped with most Linux distributions, you must download and
install them separately from the JCOP Tools.
h3. ___
Contents
h3. ___
Software Requirements
Linux distribution
The JCOP Tools simulation has been developed on a Fedora Core 6 system, but should also work in case of
many other recent Linux distributions.
Java Development Kit
The JCOP Tools have been developed and tested with the Sun JDK 1.4.2_13-b06
for Linux. Your success with other Development Kits may vary as there are
partly subtle differences across the different devlopment kits.
PCSC
The JCOP Tools use PCSC to talk with real cards on Linux. Most distributions
do not ship with Linux PCSC by default (Fedora Core 6 does), you must thus download it fromhttp://www.linuxnet.com
and install it by yourself. If you are used to software installation under Linux,
and are not afraid of compiling and installing software packages, this should
not be a hard problem. You have to download both the base PCSC package
(including PCSC daemon and client libraries) and separately the driver
for the reader you want to use. The PCSC package contains a test program
which should tell you whether your installation is set up correctly and
communicating with a card works. The JCOP Tools have been reported to
work together with Muscle PCSC version 1.3.1-7.
JPCSC
The JCOP Tools are shipped with JPCSC which you can also download athttp://www.linuxnet.com. JPCSC
is a JNI library which offers Java applications the access to PC/SC functions
by mapping their requests to an underlying native PC/SC implementation. The JCOP
Tools - mostly written in Java - thus depend on JPCSC to communicate with real cards
on Linux. JPCSC depends on a properly installed and setup PC/SC environment.
Especially, the JAVA_LIBRARY_PATH should list the directories where the
PC/SC client libraries and the native JPCSC library libjpcsc.so ( downloadable as binary from
Windows Binary Download Here )
are installed, the CLASSPATH variable should list th___
Miscellaneous
What should work
As soon as you setup your system correctly, there should only be minor differences
between using JCOP Tools on Windows or on Linux. Emulating a real JCOP,
debugging, shell, cap-file conersion should all be possible as in case of Windows.
What is missing
No drivers or tools are currently available for using JCOP30's in contactless
mode. If you need such support, please contact directly NXP
at for further assistance.
Copyright 2001,2007 IBM Corp. All rights reserved.
Edited by: lexdabear on Sep 28, 2007 4:13 PM (I hate the new edit) -
Oracle 9i Installation under Linux
I am trying to Install Oracle 9.0.1 under Linux.
During the Installation Process it has given some
error as follows..
ERROR in invoking target install of makefile
/home/oracle/OraHome1/plsql/lib/ins_plsql.mk
and also for sqlplus and ldap etc, etc.
I ignored those and after 100% completion
its going into a window and saying Configuring NetAssistant and its going into a loop somewhere because its not coming out from that loop even after several hours.
Can you suggest something.
Thanks and Regards.
KeshavCheck the url of SuSe :
http://www.suse.com/us/support/oracle/index.html
I guess you're trying to install on SuSE 7.3. Is that right ? -
Hi,
I'm trying to parse a HTML page but I always get the same error, which is the following exception:
javax.swing.text.ChangedCharSetException
In the class ParserCallback I'm using the method handleError and it shows:
req.att contentmeta?
ioexception???
just before the exception occurs.
The only line where this error occurs in the html page is:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
and I know that the exact point is the attribute 'content'. If it is removed or changed to 'contenttype' the error desappears.
The problem is that I can't change the attribute because the html page is not mine, it is caught on the Web. And I don't want to remove it.
Anybody knows what is happening?
Thanks!!i am also having a problem with html parsing in java
i have given a detailed / complete description of the problem on this link along with the log and my sample code ...
http://forum.java.sun.com/thread.jspa?threadID=643683&tstart=0
if u could see this ... -
Runtime.exec() does not work under Linux
Hi,
I have a generic application runner class that runs an external
program and redirects stdout/stderr to a buffer/file.
While everythings works just fine under Windows, I get the
following exception under Linux trying to run the Java interpreter
'java':
java.io.IOException: "/usr/lib/SunJava2-1.3.1/jre/bin/java": not found
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:139)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:546)
at java.lang.Runtime.exec(Runtime.java:413)
I have checked that the file /usr/lib/SunJava2-1.3.1/jre/bin/java
exists.
Any help appreciated!
Marccan I ask how you solved it? I am having a problem
with quotes just now to and it might help me!I simply tested what the current platform is and
only used quotes under Windows.
Marc -
JCombox does not work under linux (fedora) could you help me???
Hi All,
I am implementing a GUI for a linux application. This GUI works fine under windows system. But the JCombobox does not work under Linux system. Would you help me to solve it? Thank you very much!..
The problem is that I cannot select any other item except the first item in the dropdown box of JCombobox. There is no event generated when I click the combobox, while events are generated for other Buttons.
This problem exists for the following code when I maximize the window. When the window is minimize to some extend in my problem, it is OK.
Here is the simplify code:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.Serializable;
import java.util.Vector;
import javax.swing.ComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.event.ListDataEvent;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import java.awt.event.*;
import javax.swing.*;
//carmen
import javax.swing.filechooser.*;
import javax.swing.event.*;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.border.*;
//import AlwaysSelectableComboBoxDemo.AlwaysSelectableComboBox;
//import AlwaysSelectableComboBoxDemo.AlwaysSelectableComboBox;
import java.io.*;
import java.util.*;
import java.lang.String.*;
public class Test extends JFrame
private JComboBox jComboBox1;
private JComboBox jComboBox2;
private JPanel contentPane;
private JTabbedPane jTabbedPane1;
//Main Tab
private JPanel Main;
private JPanel OutputSimSet;
private JPanel Test;
private JPanel ScriptGenTab;
private JPanel ResultTab;
//Result Tab
private JPanel SimResult;
public Test()
super();
//initializeComponent();
contentPane = (JPanel)this.getContentPane();
jTabbedPane1 = new JTabbedPane();
Main = new JPanel();
OutputSimSet = new JPanel();
Test = new JPanel();
ScriptGenTab = new JPanel();
ResultTab = new JPanel();
SimResult = new JPanel();
jComboBox1 = new JComboBox(
new String[]{"Item 1","Item 2", "Item 3"});
jComboBox1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
System.out.println("Yeah");
jComboBox2 = new JComboBox(
new String[]{"Item 1","Item 2", "Item 3"});
jComboBox2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
System.out.println("Yeah");
// jTabbedPane1
jTabbedPane1.addTab("Main", Main);
jTabbedPane1.addTab("ScriptGenerator", ScriptGenTab);
jTabbedPane1.addTab("Simulation Result", ResultTab);
jTabbedPane1.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e)
jTabbedPane1_stateChanged(e);
// contentPane
contentPane.setLayout(new BorderLayout(0, 0));
contentPane.add(jTabbedPane1, BorderLayout.CENTER);
// Main
//Main.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
Main.setLayout(new BorderLayout(0, 0));
Main.add(OutputSimSet,BorderLayout.NORTH);
OutputSimSet.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
OutputSimSet.add(Test, 0);
Test.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
Test.add(jComboBox1,0);
//ResultTab
ResultTab.setLayout(new BorderLayout(0, 0));
ResultTab.setBorder(new TitledBorder(""));
ResultTab.add(SimResult, BorderLayout.NORTH);
SimResult.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
SimResult.add(jComboBox2,0);
// Test
this.setTitle("Test");
this.setLocation(new Point(0, 0));
this.setSize(new Dimension(600, 500));
this.setVisible(true);
public void initializeComponent()
/** Add Component Without a Layout Manager (Absolute Positioning) */
private void addComponent(Container container,Component c,int x,int y,int width,int height)
c.setBounds(x,y,width,height);
container.add(c);
// TODO: Add any appropriate code in the following Event Handling Methods
private void jTabbedPane1_stateChanged(ChangeEvent e)
System.out.println("\njTabbedPane1_stateChanged(ChangeEvent e) called.");
// TODO: Add any handling code here
// TODO: Add any method code to meet your needs in the following area
// TODO: Add any appropriate code in the following Event Handling Methods
private void jComboBox1_actionPerformed(ActionEvent e)
System.out.println("\njComboBox1_actionPerformed(ActionEvent e) called.");
Object o = jComboBox1.getSelectedItem();
System.out.println(">>" + ((o==null)? "null" : o.toString()) + " is selected.");
// TODO: Add any handling code here for the particular object being selected
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
private static void createAndShowGUI() {
//Create and set up the window.
Test frame = new Test();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}package oct03_JCBox;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
public class Test extends JFrame
private JComboBox jComboBox1;
private JComboBox jComboBox2;
private JPanel contentPane;
private JTabbedPane jTabbedPane1;
//Main Tab
private JPanel Main;
//private JPanel OutputSimSet;
//private JPanel Test;
private JPanel ScriptGenTab;
private JPanel ResultTab;
//Result Tab
//private JPanel SimResult;
public Test()
super();
//initializeComponent();
contentPane = (JPanel)this.getContentPane();
jTabbedPane1 = new JTabbedPane();
Main = new JPanel();
ScriptGenTab = new JPanel();
ResultTab = new JPanel();
// OutputSimSet = new JPanel();
// Test = new JPanel();
// SimResult = new JPanel();
jComboBox1 = new JComboBox(
new String[]{"Item 1","Item 2", "Item 3"});
jComboBox1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
System.out.println("Yeah");
jComboBox2 = new JComboBox(
new String[]{"Item 1","Item 2", "Item 3"});
jComboBox2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
System.out.println("Yeah");
// Main
//Main.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
Main.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
Main.add(jComboBox1);
//ResultTab -----
ResultTab.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
ResultTab.add(jComboBox2);
// jTabbedPane1
jTabbedPane1.addTab("Main", Main);
jTabbedPane1.addTab("ScriptGenerator", ScriptGenTab);
jTabbedPane1.addTab("Simulation Result", ResultTab);
jTabbedPane1.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e)
jTabbedPane1_stateChanged(e);
// contentPane
contentPane.setLayout(new BorderLayout(0, 0));
contentPane.add(jTabbedPane1, BorderLayout.CENTER);
// Test
this.setTitle("Test");
this.setLocation(new Point(0, 0));
this.setSize(new Dimension(600, 500));
this.setVisible(true);
public void initializeComponent()
// /** Add Component Without a Layout Manager (Absolute Positioning) */
// private void addComponent(Container container,Component c,int x,int y,int width,int height)
// c.setBounds(x,y,width,height);
// container.add(c);
// TODO: Add any appropriate code in the following Event Handling Methods
private void jTabbedPane1_stateChanged(ChangeEvent e)
System.out.println("\njTabbedPane1_stateChanged(ChangeEvent e) called.");
// TODO: Add any handling code here
// TODO: Add any method code to meet your needs in the following area
// TODO: Add any appropriate code in the following Event Handling Methods
// private void jComboBox1_actionPerformed(ActionEvent e)
// System.out.println("\njComboBox1_actionPerformed(ActionEvent e) called.");
// Object o = jComboBox1.getSelectedItem();
// System.out.println(">>" + ((o==null)? "null" : o.toString()) + " is selected.");
// // TODO: Add any handling code here for the particular object being selected
* Create the GUI and show it. For thread safety,
* this method should be invoked from the
* event-dispatching thread.
private static void createAndShowGUI() {
//Create and set up the window.
Test frame = new Test();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
} Try this - you use too many unnecessary JPanels.
Which way you prefer with actionPerformed should work either way.
I think your problem was too many unnecessary Panels and set all attributes before it is added, perhaps,
not add the panel first and then try to set attributes like layout, color, etc...
Maybe you are looking for
-
OpenSQLException: JDBC driver not supported?
Hi @ all, I need to connect to a DataSource with the WebAS 7 via SQLJ. As I try to connect to it with the SQL Engine set to "Vendor SQL" I get: "The given connection "com.sap.engine.services.dbpool.cci.ConnectionHandle" is not an Open SQL connection"
-
Making call from within web service to CRMOD
I have a page success.jsp and inside success.jsp I am calling logon() method of Session.java which makes connection using HttpURLConnection.open() while it opens, it checks for DemoTrust.jks, although I tried disabling this, but I could not in the Ap
-
The limitation of the number of iphones on one account at the AppStore
Don't you believe that this limitation should be done in some other way? In my opinion, there should be a limit for a number of iphones of the same generation. I had 2 Iphones 2G (i broke one), now I use 2 iphones 3G, and one of them was replaced due
-
I have a problem with JFileChooser.showOpenDialogBox(Component c). When I select a directory and click the Open button,the program goes wacky. Same is the case if I click Cancel button without selecting any file. How to solve this problem. I want the
-
Considering getting motion 5 but just checking that it has some essentials for me. 1. Colour removal on clips and replacing with background, basically for greenscreen stuff 2. Adding animations to clips, not just for adding titles, but importing gifs