- Tomcat
add Environment variable CATALINA_HOME
port: <tomcat>/conf/server.xml
user: <tomcat>/conf/tomcat-users.xml
<user username=”arvifox” password=”arvifox” roles=”manager-gui,manager-script,manager-status,manager-jmx”/> - GlassFish
port: GlassFish\glassfish\domains\domain1\config\domain.xml
user: go to admin to change the password
Tag: java
How to compile java. How to build jar
Why did I decide to write this post?
Because of these:
[code language=”java”]
Could not find or load main class
[/code]
or How to specify main class for console app.
Collator
Performing Locale-Independent Comparisons
[code language=”java”]
Collator c = Collator.getInstance(new Locale("ru"));
//c.setStrength(Collator.PRIMARY);
System.out.println(c.compare("JOHN", "JOHN"));
System.out.println(c.compare("JOHN", "John"));
System.out.println(c.compare("JOHN", "john"));
System.out.println("JOHN".compareTo("bill"));
[/code]
JSR 133 (Java Memory Model) FAQ
Parsing xml string in Java
[code language=”java”]
String xml = "<message>HELLO!</message>";
org.jdom.input.SAXBuilder saxBuilder = new SAXBuilder();
try {
org.jdom.Document doc = saxBuilder.build(new StringReader(xml));
String message = doc.getRootElement().getText();
System.out.println(message);
} catch (JDOMException e) {
// handle JDOMException
} catch (IOException e) {
// handle IOException
}
[/code]
[code language=”java”]
String xml = "<message>HELLO!</message>";
DOMParser parser = new DOMParser();
try {
parser.parse(new InputSource(new java.io.StringReader(xml)));
Document doc = parser.getDocument();
String message = doc.getDocumentElement().getTextContent();
System.out.println(message);
} catch (SAXException e) {
// handle SAXException
} catch (IOException e) {
// handle IOException
}
[/code]
[code language=”java”]
String xml = "<message>HELLO!</message>";
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = null;
try {
db = dbf.newDocumentBuilder();
InputSource is = new InputSource();
is.setCharacterStream(new StringReader(xml));
try {
Document doc = db.parse(is);
String message = doc.getDocumentElement().getTextContent();
System.out.println(message);
} catch (SAXException e) {
// handle SAXException
} catch (IOException e) {
// handle IOException
}
} catch (ParserConfigurationException e1) {
// handle ParserConfigurationException
}
[/code]