Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.

Public Report
Report From: JBuilder/Runtime System/Application    [ Add a report in this area ]  
Report #:  25724   Status: Reported
Native Executable Builder
Project:  JBuilder Build #:  11.0.236.0
Version:    11 Submitted By:   Girish Kulkarni
Report Type:  Issue Date Reported:  3/4/2006 7:30:07 AM
Severity:    Critical / Show Stopper Last Updated: 3/6/2006 6:38:27 AM
Platform:    All versions Internal Tracking #:  
Resolution: None  Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: 5
Description
hi,

I am using Jbuilder 2005 for converting the java application to native executable file. I am giving a test code similar to the code which I am using in that application.

When I run this through JBuilder it works fine. But when I create exe out of it and launch it on command line I get NullPointerException. I tried to find the reason. I peeped into the exe file and found that it uses -Xbootclasspath option. Because of which JVM forces the bootstrap classloader to load the class. JDK documentation for getClassLoader() says this method will return null if the class is loaded by boot strap class loader.

Please assist me in finding a way out for this. This has become a real show stopper.
Steps to Reproduce:
package Test;

import java.util.*;
import java.net.*;
import java.io.*;

public class test {
  public test() {
    System.out.println(System.getProperty("sun.boot.class.path"));
    System.out.println(getClass().getClassLoader());
    loadErrorProperties();
    System.out.println(m_errorProperties.get("2"));
  }

  private void loadErrorProperties()  {
        if (m_errorProperties == null) {
            try {
                URL url = getClass().getClassLoader().getResource("Test/Test.txt");
                if (url != null) {
                    URLConnection urlConnection = url.openConnection();
                    m_errorProperties = new Properties();
                    m_errorProperties.load(urlConnection.getInputStream());
                }
            }
            catch (IOException e) {
            }
        }
    }


  public static void main(String[] args) {
    test test1 = new test();
  }

  private static Properties m_errorProperties = null;
}
Workarounds
None
Attachment
Files.zip
Comments

Girish Kulkarni at 3/6/2006 12:58:33 AM -
Just to add to it, I have tried using JBuilder 8 (8.0.140.0), it worked absoultely fine. I am wondering how can't this be run in JBuilder 2005.

Also some how I cannot change the way I am loading the property file. (e.g. I cannot use static methods provided in ClassLoader class)

So please let me know the work around for this as soon as possible.


Thanks

Doychin Bondzhev at 4/8/2006 1:42:39 AM -
I usually place all my classes in separate jar file and inside the executable I just put config file to load this jar not from boot class path.

this way you will have 2 files but at least your code will work.

Doychin

Girish Kulkarni at 4/9/2006 10:39:48 PM -
hi Doychin,
   The main difference between JBuilder 2005 and JBuilder 8 is that JBuilder 2005 forces boot strap class loader to load the classes. Because of this, the getClassLoader method of class "Class" returns null. So whenever I call any method on this ClassLoader I get nullpointer. Some how we should force JVM not to use boot strap class loader to load the classes, instead use the system class loader. I tried adding following line in the config file.

vmparam -Xbootclasspath/p:%s

  But it still didnt work for me. Have you tried the same piece of code running with JBuilder 2005? If not please try this out. You will surely be able to reproduce this issue. As per my understanding, We have to make some changes to config file. But I have not come to a sure way out.


Thanks
Girish

Girish Kulkarni at 3/13/2006 12:54:04 AM -
This issue is reoprted a long back and it seems still not been looked at. Very Good

Server Response from: ETNACODE01