Vishal
Vishal

Reputation: 141

How to resolve java.lang.NoClassDefFoundError in install4j

Requirement: Write a script in install4j to run a method from external jar file at time of installation.

Implementation: For this we have import specific class in the script and call that method also added particular jar file in compiler variable of install4j as a class-path so script compiled successfully. And install4j created installer successfully.

Issue: At the run time I am getting NoClassDefFoundError.

I am getting following exception: In action "Run script" (screen "Installation location"), property "Script": java.lang.NoClassDefFoundError: yes/xxxxxx/Version

Even though I have added jar files path in following System properties:

sun.boot.library.path=C:\xxx\lib\version.jar;c:\program files\java\jre1.8.0_91\bin java.library.path=C:\xxxx\lib\version.jar;C:\Program Files\install4j5\bin..\lib;C:/xxxxT-214/lib;C:\jdk1.6.0_20\bin;C:\xxxxxx\;C:\xxxxxx\bin;C:\xxxxxx\jre1.5.0_06\bin;C:\xxxxxx\jre1.5.0_06\bin\classic;C:\Documents and Settings\All Users.WINDOWS\Application Data\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Gemalto\Classic Client\BIN;C:\PROGRA~1\ULTRAEDT;c:\program files\install4j5\jre\bin;c:\program files\java\jre1.8.0_91\bin java.class.path=C:\xxxxxx-214\lib\version.jar;C:\DOCUME~1\POSBuild\LOCALS~1\Temp\e4jDB.tmp_dir1490274034\i4jruntime.jar;C:\DOCUME~1\POSBuild\LOCALS~1\Temp\e4jDB.tmp_dir1490274034\user.jar;C:\DOCUME~1\POSBuild\LOCALS~1\Temp\e4jDB.tmp_dir1490274034\platform.zip;;C:\Program Files\Java\jre1.8.0_91\lib\deploy.jar;C:\Program Files\Java\jre1.8.0_91\lib\plugin.jar java.ext.dirs=C:\xxxxxx-214\lib\version.jar;c:\program files\java\jre1.8.0_91\lib\ext;C:\WINDOWS\Sun\Java\lib\ext sun.boot.class.path=C:\xxxxxx-214\lib\version.jar;c:\program files\java\jre1.8.0_91\lib\resources.jar;c:\program files\java\jre1.8.0_91\lib\rt.jar;c:\program files\java\jre1.8.0_91\lib\sunrsasign.jar;c:\program files\java\jre1.8.0_91\lib\jsse.jar;c:\program files\java\jre1.8.0_91\lib\jce.jar;c:\program files\java\jre1.8.0_91\lib\charsets.jar;c:\program files\java\jre1.8.0_91\lib\jfr.jar;c:\program files\java\jre1.8.0_91\classes

Could you please help to sort out this issue.

Upvotes: 1

Views: 983

Answers (1)

Ingo Kegel
Ingo Kegel

Reputation: 47965

For a JAR file that is available at compile-time, you have to add it on the Installer->Custom Code and Resources tab. There is no need to modify any class path.

For a JAR file that is only available at run-time, you can call

context.addToClassPath(new File("path to jar file"));

in a "Run script" action.

Upvotes: 1

Related Questions