Giter VIP home page Giter VIP logo

core-java's People

Contributors

mkyong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

core-java's Issues

xml crashes when running on eclipse 06-2023 with Java 19

I have java19 and 20 installed on Eclipse 06-2023. I also installed maven with your pom.xml. Here are the issues.
1). Alexa.com disabled their service around 2021/2022. Thus the two alexa java files crash when running as java application regardless in run on maven setup or the JDT default Eclips 06-2023.
2). The following three files ReadXmlParser, ReadXmlParserLoop and ReadXmSaxParser2 will work in a Maven setup but will not run in a default JDT Eclipse 06-2023 setup with java 19 and all the java file dependencies imported one-by-one.

ReadXmlParser

Exception in thread "main" java.lang.IllegalArgumentException: InputStream cannot be null
	at java.xml/javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:118)
	at com.mkyong.xml.dom.ReadXmlDomParser.main(ReadXmlDomParser.java:36)

ReadXmlParserLoop

Exception in thread "main" java.lang.IllegalArgumentException: InputStream cannot be null
	at java.xml/javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:118)
	at com.mkyong.xml.dom.ReadXmlDomParserLoop.main(ReadXmlDomParserLoop.java:30)

ReadXmlSaxParser2

java.net.MalformedURLException: Cannot invoke "String.length()" because "spec" is null
	at java.base/java.net.URL.<init>(URL.java:798)
	at java.base/java.net.URL.<init>(URL.java:646)
	at java.base/java.net.URL.<init>(URL.java:582)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:651)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:150)
	at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:861)
	at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:825)
	at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1224)
	at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:637)
	at com.mkyong.xml.sax.ReadXmlSaxParser2.main(ReadXmlSaxParser2.java:45)
Caused by: java.lang.NullPointerException: Cannot invoke "String.length()" because "spec" is null
	at java.base/java.net.URL.<init>(URL.java:704)
	... 10 more

3). The ReadXmlSaxParserXXE will not run on a maven setup using your pom.xml file, nor on the defaul JDT Eclipse 06-2023 install.

Start Document
org.xml.sax.SAXParseException; systemId: file:///C:/Users/myinc/eclipse-workspace/Lang_Java/Java_Code/src/main/resources/staff-xxe.xml; lineNumber: 2; columnNumber: 10; DOCTYPE is disallowed when the feature "http://apache.org/xml/features/disallow-doctype-decl" set to true.
	at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204)
	at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:178)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:400)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1465)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:898)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:542)
	at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:889)
	at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:825)
	at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1224)
	at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:637)
	at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:326)
	at java.xml/javax.xml.parsers.SAXParser.parse(SAXParser.java:276)
	at com.mkyong.xml.sax.ReadXmlSaxParserXXE.main(ReadXmlSaxParserXXE.java:32)

Other than this, the result of the java files will run on both the maven setup and the default JDT setup for Eclipse 06-2023.
I'm still pretty new to Eclipse, and looking at these example files to see how these work.

Reading file exception

Reading the File works when app is executed from the IDE, but if you compile and execute:

javac Main.java
java Main

then it throws:

Exception in thread "main" java.lang.IllegalArgumentException: File: app.log not found.
	at ResourceHelper.getAbsoluteFilePath(ResourceHelper.java:11)
	at Main.main(Main.java:15)

ResourceHelper.java:

public class ResourceHelper {

    public static String getAbsoluteFilePath(String filename) {
        URL resource = ClassLoader.getSystemClassLoader().getResource(filename);
        if (resource == null) {
            throw new IllegalArgumentException("File: " + filename + " not found.");
        }

        try {
            Path path = Paths.get(resource.toURI());
            return path.toString();
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException(e.getMessage());
        }
    }

}

Any suggestion to solve this?

java-xml/PrintAllHandlerSax incorrect handling of nested nodes

When you add printing value of staff node, it turns out that it has the value of the last nested node (bio):

@Override
    public void endElement(String uri,
                           String localName,
                           String qName) {
...
        if (qName.equalsIgnoreCase("staff")) {
            System.out.printf("staff : %s%n", currentValue.toString());
        }
}

console before:

End Element : bio
Bio : HTML tag <code>testing</code>
End Element : staff
Start Element : staff
Staff id : 1002

console after:

Bio : HTML tag <code>testing</code>
End Element : staff
staff : HTML tag <code>testing</code>
Start Element : staff
Staff id : 1002

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.