Java Development Stuff

From The Dubins
Jump to: navigation, search

1.5 New Features

New Feature list and Info

Using Properties

System.getProperty("line.separator")

System.properties available


Collections related

Linked list or ArrayList

Compile a Java program to an executable on Windows

Article

Spring

Blog

Obtaining Spring using Maven

Web Services

AXIS

REST online course

CodeRanch WS Info

AspectJ

AspectJ Guide

JVM Tuning

JVM Tuning info


    -Xms256m -Xmx1280m -Xss6m
    StackOverflowError

Security Stuff

JAAS guide

Paramter Passing

Paramter passing in Java

Java is Pass By Value

Javawold explanation

Code example


Running Java app as a Service

Java Service Wrapper


YAJSW

Spring Stuff

SessionFactory.getCurrentSession() vs HibernateTemplate

Dependency Injection Article


Spring Live eBook


AOP Config info

CRUD Impl example

Maven Stuff

Null pointer and dependencies won't resolve


Could not resolve archetype from any of the configured repositories.

To clean out and redownloand and setup all dependancies, use this: mvn -U clean install


Finding zero dependencies

Better about finding zero dependencies


    Manually adding jars to your repo
    
    mvn install:install-file -Dfile=<path-to-file> -DgroupId=<group-id> \
   -DartifactId=<artifact-id> -Dversion=<version> -Dpackaging=<packaging>
   
   Example:
   mvn install:install-file -Dfile=e:\tools-1.5.0.jar -DgroupId=com.sun.tools -DartifactId=tools -Dversion=1.5.0 -Dpackaging=jar

Hibernate Stuff

Hibernate Tools Plugin - generate Entity Classes from Database


Info at JBOSS for the Tools installation


Setup encrypted db password

forum post

 

     Use the command line utility to encrypt the pwd:  jasypt-1.9.0\bin>encrypt input="UserNAME" password="PWD"

     This goes in the Hibernate Utility file.

     StandardPBEStringEncryptor strongEncryptor = new StandardPBEStringEncryptor();
     HibernatePBEEncryptorRegistry registry = HibernatePBEEncryptorRegistry.getInstance();
     strongEncryptor.setPassword("password");
     registry.registerPBEStringEncryptor("configurationHibernateEncryptor",
                strongEncryptor);

     And in the hibernate.cfg.xml

        <!-- Database connection settings -->
		<property name="connection.provider_class">
			org.jasypt.hibernate4.connectionprovider.EncryptedPasswordC3P0ConnectionProvider
		</property>
		<property name="connection.encryptor_registered_name">
			configurationHibernateEncryptor
		</property>

		<property name="connection.url">jdbc:mysql://localhost/reportsdb</property>
		<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
		<property name="connection.username">USERNAME</property>
		<property name="connection.password">ENC(ENCRYPTED PWD)</property>
  

Executable Jar

Assembly Plugin

Creating an executable jar file

Running:
set PATH=%PATH%;%JAVA_HOME%\bin
java -jar your_jar_file-1.0.1-jar-with-dependencies.jar

Using Maven:

Place this markup before the <dependencies> tag

<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jar-plugin</artifactId>
				<version>2.3.1</version>
				<configuration>
					<archive>
						<manifest>
							<addClasspath>true</addClasspath>
							<mainClass>com.thedubins.ClassFile</mainClass>
						</manifest>
					</archive>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-assembly-plugin</artifactId>
				<version>2.2.1</version>
				<configuration>
					<archive>
						<manifest>
							<addClasspath>true</addClasspath>
							<mainClass>com.thedubins.ClassFile</mainClass>
						</manifest>
					</archive>
					<descriptorRefs>
						<descriptorRef>jar-with-dependencies</descriptorRef>
					</descriptorRefs>
				</configuration>
			</plugin>
		</plugins>
	</build>
	<dependencies>
 

Hiding non-hidden HTML inputs

     <div id="divCheckbox" style="visibility: hidden;">	
          <@s.checkbox name="someClass.someInstanceVariable" id="someId"/>
     </div>
 


Setup m2eclipse


Help | Install New Software 
In the "Install" dialog: click the Add button 
In the "Add Site" dialog: 
Name: m2eclipse 
Location: http://m2eclipse.sonatype.org/update/ 
Click OK 
Back in the "Install" dialog, in the "Add Site" dropdown, select: m2eclipse 
Under "Maven Integration", I checked: 
"Maven Integration for Eclipse (Required)" 
"Maven POM Editor (Optional)" 
"Maven POM XML Editor (Optional)" 
Click Next, go through and complete the Install wizard. 
When prompted, I restarted Eclipse. 
That got my Maven POM editor up and running in Eclipse 3.5.
 


eclipse

Install m2e Maven Integration for eclipse Jalopy drop-in


    Error running builder 'JavaScript Validator'
    
    To fix go to Project->Properties->Builders then disable ‘Javascript Validator’.

Blogs etc

ENUM Singleton

ENUM