Here you can find the source of createClassLoader(String fileName)
static public URLClassLoader createClassLoader(String fileName)
//package com.java2s; /**//from www.j a v a 2s . c o m * This file is part of Spritnesse. * <p/> * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. * <p/> * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. * <p/> * You should have received a copy of the GNU Lesser General Public License along with this library. * <p/> * Copyright (c) 2014, Andrew Oxenburgh, All rights reserved. */ import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; public class Main { static public URLClassLoader createClassLoader(String fileName) { String urlPath = makeUrlPath(fileName); URL url = null; try { url = new URL(urlPath); } catch (MalformedURLException e) { throw new RuntimeException(e); } URLClassLoader loader = URLClassLoader.newInstance(new URL[] { url }); return loader; } static private String makeUrlPath(String fileName) { String path = new File(".").getAbsolutePath(); path = path.substring(0, path.length() - 2); return "file:///" + path + "/" + fileName; } }