Wrox Programmer Forums
Java GUI Discussions specific to programming Java GUI.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java GUI section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old February 2nd, 2005, 07:54 AM
Registered User
Join Date: May 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default ClassLoader

    i'm trying to load class files from provided jar file.i'm creating ClassLoader onject and calling defineClass.. method for every class in jar.my problem is that,i'msuccess fully able to load some classes while some classes throws java.lang.ClassFormaError. can anybody suggest me a fine solution.i've included my code snippet which looks after this loading unction...

    private Class loadClass(final JarEntry jarentry) {
        try {
            Class loadedclass = new ClassLoader() {
                public Class findClass(String name) {
                    try {
                        InputStream is = jarfile.getInputStream(jarentry);
                        int available = is.available();
                        byte data[] = new byte[available];
                        name = parseClassName(name);
                        try {
                            return defineClass(name, data, 0, data.length);
                        }catch(ClassFormatError err) {
                            System.out.println(err+"class not loaded :"+name );
                            return null;
                    }catch(IOException ex) {
                        return null;
                return loadedclass;
             }catch(Exception e) {
                   return null;

Thanks... <center></center><div align="left"></div id="left"><center></center>

Similar Threads
Thread Thread Starter Forum Replies Last Post
Tomcat 5, XML and writing your own classloader lawrencewinkler BOOK: Professional Apache Tomcat 0 September 28th, 2004 03:46 PM
ClassLoader zuodp Servlets 0 November 11th, 2003 03:38 AM
classloader help ambharish Java Espanol 2 July 23rd, 2003 03:49 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.