Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > J2EE
J2EE General J2EE (Java 2 Enterprise Edition) discussions. Questions not specific to EE will be redirected elsewhere.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the J2EE 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, 08:09 AM
Registered User
Join Date: May 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamically Class Loading form jar

    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;


Old February 28th, 2005, 05:41 AM
Registered User
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

try looking at this site I belive it could help you:

Similar Threads
Thread Thread Starter Forum Replies Last Post
loading an image dynamically into my report orson4music Crystal Reports 1 January 4th, 2008 09:35 AM
Loading forms dynamically bmains C# 2005 1 November 30th, 2005 03:53 PM
dynamically loading table using javascript bkalyanchakri Javascript How-To 1 November 1st, 2005 07:21 AM
Loading user control dynamically from code-behind jacob ASP.NET 1.0 and 1.1 Basics 2 April 12th, 2004 06:06 PM

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