Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2008 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     Rafael Oliveira Nbrega <rafael.oliveira@gmail.com> - bug 230232
 *******************************************************************************/

import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;

public class Main {
    public static boolean isOnClasspath(String fullyQualifiedName, IJavaProject project) {
        if (fullyQualifiedName.indexOf('$') != -1)
            fullyQualifiedName = fullyQualifiedName.replace('$', '.');
        try {
            IType type = project.findType(fullyQualifiedName);
            return type != null && type.exists();
        } catch (JavaModelException e) {
        }
        return false;
    }
}