if (this.wtkHome != null) {
if (this.wtkHome != null && ((new File(this.wtkHome)).exists()) ) {
	public void checkSettings() {		//System.out.println( getProject().getBaseDir().getAbsolutePath() );		if (this.infoSetting == null) {			throw new BuildException("Nested element [info] is required.");		}		if (this.buildSetting == null) {			throw new BuildException("Nested element [build] is required.");		}		if (this.deviceRequirements == null) {			log("Nested element [deviceRequirements] is missing, now the project will be optimized for all known devices.");		}		// check the nested element of <build>:		Midlet[] midlets = this.buildSetting.getMidlets(); 		if (midlets == null || midlets.length == 0) {			// check for main class or iappli class:			if ( this.buildSetting.getMainClassSetting() == null					&& this.buildSetting.getDojaClassSetting() == null					) 			{								throw new BuildException("Midlets need to be defined in the <build>-section with either <midlets> or <midlet>. Alternatively you might use a <iappli> or <main> element for defining the DoJa main class or the BlackBerry main class.");			}		}		// now check if the midlets do exist:		SourceSetting[] sources = this.buildSetting.getSourceSettings();		//if (!this.buildSetting.useDefaultPackage()) {			for (int i = 0; i < midlets.length; i++) {				Midlet midlet = midlets[i];				String fileName = StringUtil.replace( midlet.getClassName(), '.', File.separatorChar) + ".java";				boolean midletFound = false;				for (int j = 0; j < sources.length; j++) {					SourceSetting setting = sources[j]; 					File sourceDir = setting.getDir();					String sourceDirPath = sourceDir.getAbsolutePath();					File midletFile = new File( sourceDirPath + File.separator + fileName );					if (midletFile.exists()) {						midletFound = true;						break;					}				}				if (!midletFound) {					String message = "The MIDlet [" + midlet.getClassName() + "] could not be found. Check your <midlet>-setting in the file [build.xml] or adjust the [sourceDir] attribute of the <build>-element.";					if ( midlet.getClassName().indexOf('.') != -1) {						if (sources.length > 1) {							message += "The MIDlet should be in ${src}" + File.separatorChar + fileName + ", where ${src} is one your source folders.";						} else {							message += "The MIDlet should be in " + sources[0].getDir().toString()  + File.separatorChar + fileName;						}					}					throw new BuildException( message );				}			}		//}		// check if the ant-property wtk.home or alternatively mpp.home has been set:		//e.g. with: <property name="wtk.home" value="c:\Java\wtk-1.0.4"/>		this.wtkHome = getProject().getProperty("wtk.home");		String mppHome = getProject().getProperty("mpp.home");		if (this.buildSetting.getPreverify() == null) {			// no preverify has been set, that's okay when the wtk.home ant-property has been set:			if (this.wtkHome == null && mppHome == null) { 				System.err.println("Warning: Nested element [build] should define the attribute [preverify] which points to the preverify-executable of the wireless toolkit. Alternatively you can set the home directory of the Wireless Toolkit by defining the Ant-property [wtk.home]: <property name=\"wtk.home\" location=\"C:\\WTK2.3\"/>\nAnother option is to set the \"mpp.home\" property that points to the installation directory of the MPowerPlayer SDK.\nThese settings are only necessary when you target MIDP devices, though.");			}			if (this.wtkHome != null) {				File wtkHomeFile = new File( this.wtkHome );				if ( !wtkHomeFile.exists() ) {					wtkHomeFile = new File( getProject().getBaseDir(), this.wtkHome );					if ( wtkHomeFile.exists() ) {						this.wtkHome = wtkHomeFile.getAbsolutePath();					}				}								if (!this.wtkHome.endsWith( File.separator )) {					this.wtkHome += File.separator;				}			}			File preverifyFile = null;			if (this.wtkHome != null) {				String preverifyPath = this.wtkHome + "bin" + File.separator + "preverify";				if ( File.separatorChar == '\\') {					preverifyPath += ".exe";				}				preverifyFile = new File( preverifyPath );			} else if (mppHome != null) {				if (!mppHome.endsWith(File.separator)) {					mppHome += File.separator;				}				String preverifyPath = mppHome + "osx" + File.separator + "preverify" + File.separator + "preverify";				preverifyFile = new File( preverifyPath );				//if (preverifyFile.)			}			if (preverifyFile != null) {				if (preverifyFile.exists()) {					this.buildSetting.setPreverify( preverifyFile.getAbsolutePath() );				} else if (this.wtkHome != null) {					// probably the wtk.home path is wrong:					File file = new File( this.wtkHome );					if (!file.exists()) {						throw new BuildException("The Ant-property [wtk.home] points to the non-existing directory [" + this.wtkHome + "]. Please adjust his setting in the build.xml file.");					} else {						throw new BuildException("Unable to find the preverify tool at the default location [" + preverifyFile.getAbsolutePath() + "]. Please specify where to find it with the \"preverify\"-attribute of the <build> element (in the build.xml file) or specify the \"wtk.home\" property.");					}				}			}		}	}