Board index » jbuilder » JBuilder 9 and X issues w/ executables and JavaHelp

JBuilder 9 and X issues w/ executables and JavaHelp


2004-02-26 05:14:15 AM
jbuilder21
Hello folks,
Whenever we include a JavaHelp 2 (jh.jar) dependency in our Application archive it consistently fails to open the executable jar file saying that it can not find the main class or shows no warning.
However, once I remove the JavaHelp dependency the jar executes properly. This is similar to the manifest creation bug on how JBuilder 9 created the win executables. However, in this case I am working with jar files and using Jbuilder's 9 and X.
If there is a bug could you pls recommend a workaround?
Thank you,
Richard
 
 

Re:JBuilder 9 and X issues w/ executables and JavaHelp

Richard wrote:
Quote
Whenever we include a JavaHelp 2 (jh.jar) dependency in our Application
archive it consistently fails to open the executable jar file saying that
it can not find the main class or shows no warning.
What happens if you execute:
java -cp yourjar.jar your.main.class.is.ThisOne
Quote
However, once I remove the JavaHelp dependency the jar executes properly.
This is similar to the manifest creation bug on how JBuilder 9 created the
win executables. However, in this case I am working with jar files and
using Jbuilder's 9 and X.
Inspect the jar file and see what the content of the manifest of the jh.jar
is.
--
Ruurd
 

Re:JBuilder 9 and X issues w/ executables and JavaHelp

Aloha Pels,
Thank you for responding. I navigated to the directory containing the jar file and executed the command you suggested.
I also have 2 other applications with similar jar files and navigated to those locations and executed the command you suggested.
On all occassions the outputs reads "NoClassDefFoundError"
However, when I unzip the jar file it clearly contains the class file (containing the "main method"). I also look at the "manifest" file and it too clearly states the correct path to the same class file (containing the "main method").
I can still execute these jar file and successfully run my application as long as I DO NOT have JavaHelp (jh.jar) listed as one of the dependencies in JBuilder's archive builder.
I also did as you recommended and looked at the jh.jar manifest file. The file is extensively long. What do you recommend I do with this jh.jar manifest file? Or should I edit the application's manifest files?
To see what I mean create a simple project using JBuilder. Place JavaHelp
(jh.jar) as one of your required libraries and as a dependency in the
archive Builder for an Application build. Make the jar and try
executing it and it will not execute. Remove JavaHelp from the archive
dependency and the jar file will execute fine. Why is this?
Thank you again,
Richard
"R.F. Pels" < XXXX@XXXXX.COM >wrote:
Quote
Richard wrote:

>Whenever we include a JavaHelp 2 (jh.jar) dependency in our Application
>archive it consistently fails to open the executable jar file saying that
it can not find the main class or shows no warning.

What happens if you execute:

java -cp yourjar.jar your.main.class.is.ThisOne

>However, once I remove the JavaHelp dependency the jar executes properly.
>This is similar to the manifest creation bug on how JBuilder 9 created the
>win executables. However, in this case I am working with jar files and
>using Jbuilder's 9 and X.

Inspect the jar file and see what the content of the manifest of the jh.jar
is.

--
Ruurd
 

{smallsort}

Re:JBuilder 9 and X issues w/ executables and JavaHelp

Richard wrote:
Quote
Aloha Pels,
Ruurd please.
Quote
Thank you for responding. I navigated to the directory containing the jar
file and executed the command you suggested.
Ok...
Quote
I also have 2 other applications with similar jar files and navigated to
those locations and executed the command you suggested.
Ok...
Quote
On all occassions the outputs reads "NoClassDefFoundError"
However, when I unzip the jar file it clearly contains the class file
(containing the "main method"). I also look at the "manifest" file and it
too clearly states the correct path to the same class file (containing the
"main method").
Ok...
Quote
I can still execute these jar file and successfully run my application as
long as I DO NOT have JavaHelp (jh.jar) listed as one of the dependencies
in JBuilder's archive builder.
Ok.
Quote
I also did as you recommended and looked at the jh.jar manifest file. The
file is extensively long. What do you recommend I do with this jh.jar
manifest file? Or should I edit the application's manifest files?
It probably contains MD5 hashes for all classes. That way you or others
cannot tamper with them. Is there a referral to a Main-Class in there? My
wild guess is that that might be a problem.
Quote
To see what I mean create a simple project using JBuilder. Place JavaHelp
(jh.jar) as one of your required libraries and as a dependency in the
archive Builder for an Application build. Make the jar and try
executing it and it will not execute. Remove JavaHelp from the archive
dependency and the jar file will execute fine. Why is this?
Haven't the foggiest. It might be a problem with the MD5 hashes in the
manifest in the jh.jar. Alternative approach. Put the jh.jar alongside the
jar containing your app and try
java -cp yourjar.jar;jh.jar your.main.class.is.ThisOne
from the commandline, see what happens, then try
java -cp jh.jar;yourjar.jar your.main.class.is.ThisOne
and see what happens. I assume you run on Windows, otherwise replace the ';'
between the names of the jar files with a ':'.
--
Ruurd
 

Re:JBuilder 9 and X issues w/ executables and JavaHelp

Richard wrote:
Quote
Whenever we include a JavaHelp 2 (jh.jar) dependency in our
Application archive it consistently fails to open the executable
jar file saying that it can not find the main class or shows no
warning.
This problem not only exists with Jbuilder 9 but as well with JBuilder
X. Whenever we include JavaHelp dependency in our Application archive
it consistently fails to execute saying that it can not find the main
class or shows no warning. I suspect there is something wrong with how
a manifest file is created in JBuilder similar to the bug that already
exists with JBuilder's 9 lib.win.exe. But this is with the jar
creation.
I constructed the simplest demo of this, and
I think I see what is happening.
1. I created and ran the simplest possible demo of
creating an application archive:
- it calls a main() that simply prints to the console, "Success";
- it includes the jh.jar dependency "Always include ...".
- a runtime configuration of type "Executable JAR" was
created, it points to the "Application" archive, main
class = "Main".
- running it from *within* JBuilder catches an
exception which you probably weren't seeing:
a "SecurityException". From the command line,
you probably only saw the "Could not find main
class. Program will exit." message which I also
see in a separate window which opens *behind*
JBuilder (not very useful!).
2. I went to the archives of the JavaHelp forum
the URL of which is on the
java.sun.com/products/javahelp/download_binary.html
(It may be found elsewhere; I found it there because I had
to download JavaHelp in order to try to solve this problem.)
- searched on keywords: "signature file entry"
which I thought might be the shortest meaningful
part of the exception message.
- got three hits and the thread is very enlightening: long
and short of it is that you cannot unpack the jh.jar
and then include those classes in your application JAR.
This causes a security exception, which then causes
the program to abort.
(Having gone to the JavaHelp forum's archive was the
key. Without that archive, I would have thrashed
away at this problem and perhaps not figured out
what was going on. I emphasize this point because
I have found it to be essential to always search the
entire Web whenever I encounter a problem. I frequently
search the JBuilder newsgroup archives, simply because
I cannot possibly know the answer to so many questions
without doing some research of my own.)
Why does this happen in your case? If you look
at the application JAR you made by double-clicking
on its node in the Project Pane, you'll see that
the jh.jar has been unpacked and all its files
have been packed into your JAR. Bad news.
Good news: you can add the jh.jar as a JAR
into your application archive by employing
a few straightforward remedies in JBuilder.
1. Exclude the JavaHelp library in the "Dependencies"
page of the Application archive's properties. Select
"Never include ...."
2. Add a Directory View to the project in the Project
Pane. The target directory is the JavaHelp/lib folder.
Set the filtering to "Use: Wildcards" with file pattern
set to "jh.*" (without the double-quotes which I use
here to delineate the pattern). OK.
3. Right-click on the "jh.jar" node in that directory
view. Select "Properties...", and just under "Build"
select "Copy". Don't select the "Copy" to the right
of the list down below.
4. Clean the project, and if necessary clean your
application archive node. Rebuild the project,
and if necessary, rebuild your archive node.
5. Expand the JAR node inside the archive node.
You should see
myapp.jar
/META-INF
/your_top_level_package
- jh.jar
Run this. It should succeed.
--
Paul Furbacher (TeamB)
Save time, search the archives:
www.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
www.visi.com/~gyles19/fom-serve/cache/1.html
Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
--
Paul Furbacher (TeamB)
Save time, search the archives:
www.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
www.visi.com/~gyles19/fom-serve/cache/1.html
Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
 

Re:JBuilder 9 and X issues w/ executables and JavaHelp

Paul Furbacher [TeamB] wrote:
Quote
Run this. It should succeed.
It didn't when I tried it. It sounds cool though. My JAR file contains
only my test class, no jh.jar even though it says it should be copied on
Build. In fact, my classes directory doesn't have it either.
If I manually copy jh.jar to my classes directory, it does get included
in my JAR file, but JBuilder doesn't seem to be doing the copy itself.
I'm not sure it matters though. Even if I get the JAR file created as
you described, I can't actually use any of the JavaHelp classes. If I
change my main method to:
public static void main(String[] args) {
new javax.help.HelpSetException("test").printStackTrace();
}
then I get a ClassNotFoundException for the HelpSetException class.
You've ensured that jh.jar is inside my JAR file, but the VM doesn't
recursively add JAR's inside JAR's to the classpath.
--
Gillmer J. Derge (TeamB)
 

Re:JBuilder 9 and X issues w/ executables and JavaHelp

Paul Furbacher [TeamB] wrote:
Quote
- running it from *within* JBuilder catches an
exception which you probably weren't seeing:
a "SecurityException". From the command line,
you probably only saw the "Could not find main
class. Program will exit." message which I also
see in a separate window which opens *behind*
JBuilder (not very useful!).
Ah, right. The old problem where "ClassNotFound" doesn't really mean
class not found. It means "unable to load class" which can occur for a
variety of reasons.
--
Gillmer J. Derge (TeamB)
 

Re:JBuilder 9 and X issues w/ executables and JavaHelp

Gillmer,
Pls refer to the Paul Furbacher solution I posted. Thank you for your assistance. It seems when included as a dependency the archive builder unpacks the JavaHelp jh.jar. Instead there is a way in JBuilder to copy just the unpack version of jh.jar into an application jar.
Richard
"Gillmer J. Derge (TeamB)" < XXXX@XXXXX.COM >wrote:
Quote
Paul Furbacher [TeamB] wrote:
>- running it from *within* JBuilder catches an
>exception which you probably weren't seeing:
>a "SecurityException". From the command line,
>you probably only saw the "Could not find main
>class. Program will exit." message which I also
>see in a separate window which opens *behind*
>JBuilder (not very useful!).

Ah, right. The old problem where "ClassNotFound" doesn't really mean
class not found. It means "unable to load class" which can occur for a
variety of reasons.

--
Gillmer J. Derge (TeamB)
 

Re:JBuilder 9 and X issues w/ executables and JavaHelp

Thank your Ruurd,
Pls refer to the Paul Furbacher solution I posted. Thank you for your assistance. It seems when included as a dependency the archive builder unpacks the JavaHelp jh.jar. Instead there is a way in JBuilder to copy just the unpack version of jh.jar into an application jar.
Richard
"R.F. Pels" < XXXX@XXXXX.COM >wrote:
Quote
Richard wrote:

>Aloha Pels,

Ruurd please.

>Thank you for responding. I navigated to the directory containing the jar
>file and executed the command you suggested.

Ok...

>I also have 2 other applications with similar jar files and navigated to
>those locations and executed the command you suggested.

Ok...

>On all occassions the outputs reads "NoClassDefFoundError"
>However, when I unzip the jar file it clearly contains the class file
>(containing the "main method"). I also look at the "manifest" file and it
>too clearly states the correct path to the same class file (containing the
>"main method").

Ok...

>I can still execute these jar file and successfully run my application as
>long as I DO NOT have JavaHelp (jh.jar) listed as one of the dependencies
>in JBuilder's archive builder.

Ok.

>I also did as you recommended and looked at the jh.jar manifest file. The
>file is extensively long. What do you recommend I do with this jh.jar
>manifest file? Or should I edit the application's manifest files?

It probably contains MD5 hashes for all classes. That way you or others
cannot tamper with them. Is there a referral to a Main-Class in there? My
wild guess is that that might be a problem.

>To see what I mean create a simple project using JBuilder. Place JavaHelp
>(jh.jar) as one of your required libraries and as a dependency in the
>archive Builder for an Application build. Make the jar and try
>executing it and it will not execute. Remove JavaHelp from the archive
>dependency and the jar file will execute fine. Why is this?

Haven't the foggiest. It might be a problem with the MD5 hashes in the
manifest in the jh.jar. Alternative approach. Put the jh.jar alongside the
jar containing your app and try

java -cp yourjar.jar;jh.jar your.main.class.is.ThisOne

from the commandline, see what happens, then try

java -cp jh.jar;yourjar.jar your.main.class.is.ThisOne

and see what happens. I assume you run on Windows, otherwise replace the ';'
between the names of the jar files with a ':'.


--
Ruurd
 

Re:JBuilder 9 and X issues w/ executables and JavaHelp

Gillmer J. Derge (TeamB) wrote:
Quote
Paul Furbacher [TeamB] wrote:

>Run this. It should succeed.


It didn't when I tried it. It sounds cool though. My JAR file contains
only my test class, no jh.jar even though it says it should be copied on
Build. In fact, my classes directory doesn't have it either.

If I manually copy jh.jar to my classes directory, it does get included
in my JAR file, but JBuilder doesn't seem to be doing the copy itself.
Oh my. It turns out that I had gone into the
"Contents" page of the archiver node's Properties
dialog, and added jh.jar via "Add files...".
That's probably how it got in there. (I guess
I did too much flailing without taking notes.)
Quote
I'm not sure it matters though. Even if I get the JAR file created as
you described, I can't actually use any of the JavaHelp classes. If I
change my main method to:

public static void main(String[] args) {
new javax.help.HelpSetException("test").printStackTrace();
}

then I get a ClassNotFoundException for the HelpSetException class.
You've ensured that jh.jar is inside my JAR file, but the VM doesn't
recursively add JAR's inside JAR's to the classpath.
Ah, you are right. I didn't construct my simplest
of simple demos to actually call into the library.
I'm guilty of trying too enthusiastically to
get JBuilder to add that JAR to the archive
without thinking through all the consequences.
Oh well.
Basically, the only solution is to include the
jh.jar separately and to specify it on the
command-line in the -classpath option as in:
d:/myapp
myapp.bat
/lib
- myapp.jar
- jh.jar
where myapp.bat does something like this
set myappjar=./lib/myapp.jar
set jh=./lib/jh.jar
java -classpath %myappjar%;%jh% org.x.Main
--
Paul Furbacher (TeamB)
Save time, search the archives:
www.borland.com/newsgroups/ngsearch.html
Is it in Joi Ellis's Faq-O-Matic?
www.visi.com/~gyles19/fom-serve/cache/1.html
Finally, please send responses to the newsgroup only.
That means, do not send email directly to me.
Thank you.
 

Re:JBuilder 9 and X issues w/ executables and JavaHelp

Paul Furbacher [TeamB] wrote:
Quote
Basically, the only solution is to include the
jh.jar separately and to specify it on the
command-line in the -classpath option as in:
That's the same conclusion I've come to. Or maybe you could override
the manifest of the project's JAR file and include the entire contents
of the JavaHelp manifest with the signatures. I haven't tried that, so
I don't know whether it would work, but even if it does (seems to me
like it ought to), that's an awful solution.
Should this be considered a bug? Should JBuilder be copying those
signatures automatically?
--
Gillmer J. Derge (TeamB)
 

Re:JBuilder 9 and X issues w/ executables and JavaHelp

Richard wrote:
Quote
If there is a bug could you pls recommend a workaround?
After investigating this further, it's my opinion that this is indeed a
bug, but the good news is I also found a workaround.
The problem has to do with the way signed jars work. It's explained
better at the URL below than I can do myself.
java.sun.com/docs/books/tutorial/jar/sign/intro.html
What happens when you pick "Always include ..." for the jh.jar file is
that JBuilder copies the META-INF/SUN_MICR.RSA and META-INF/SUN_MICR.SF
files from jh.all, but it doesn't copy the signatures that are within
the manifest. As a result you end up with what is essentially a half
signed JAR, which naturally gets rejected by the verifier.
The solution is to prevent JBuilder from including those signature
files. Then you have a normal, unsigned JAR instead of a half signed
JAR. The easiest way to do that is to include your own, empty
META-INF/SUN_MICR.RSA and META-INF/SUN_MICR.SF files. JBuilder won't
overwrite them with the ones in jh.jar.
1. Create a META-INF directory in your source directory. Typically that
means you want to create src/META-INF
2. Create empty SUN_MICR.RSA and SUN_MICR.SF files in that directory.
3. Open the Properties dialog for the Application archive, and on the
"Content" page, add those two files.
FYI, in general it's better to reply within the same thread rather than
creating a new one. We now have 3 or 4 separate threads all discussing
this same issue independently.
--
Gillmer J. Derge (TeamB)
 

Re:JBuilder 9 and X issues w/ executables and JavaHelp

Gillmer,
Thank you for finding a final solution to this important issue. I have done what you recommended and it works perfect - thank you so much.
I have since notified Roger Brinkly from Sun JavaHelp and posted your workaround in the JavaHelp mailing list. You are developing quite a good reputation.
This solution is sort of hiddened within the newgroup should I post a FINAL SOLUTION thread?
Thank you again,
Richard
"Gillmer J. Derge (TeamB)" < XXXX@XXXXX.COM >wrote:
Quote
Richard wrote:
>If there is a bug could you pls recommend a workaround?

After investigating this further, it's my opinion that this is indeed a
bug, but the good news is I also found a workaround.

The problem has to do with the way signed jars work. It's explained
better at the URL below than I can do myself.

java.sun.com/docs/books/tutorial/jar/sign/intro.html

What happens when you pick "Always include ..." for the jh.jar file is
that JBuilder copies the META-INF/SUN_MICR.RSA and META-INF/SUN_MICR.SF
files from jh.all, but it doesn't copy the signatures that are within
the manifest. As a result you end up with what is essentially a half
signed JAR, which naturally gets rejected by the verifier.

The solution is to prevent JBuilder from including those signature
files. Then you have a normal, unsigned JAR instead of a half signed
JAR. The easiest way to do that is to include your own, empty
META-INF/SUN_MICR.RSA and META-INF/SUN_MICR.SF files. JBuilder won't
overwrite them with the ones in jh.jar.

1. Create a META-INF directory in your source directory. Typically that
means you want to create src/META-INF

2. Create empty SUN_MICR.RSA and SUN_MICR.SF files in that directory.

3. Open the Properties dialog for the Application archive, and on the
"Content" page, add those two files.

FYI, in general it's better to reply within the same thread rather than
creating a new one. We now have 3 or 4 separate threads all discussing
this same issue independently.

--
Gillmer J. Derge (TeamB)
 

Re:JBuilder 9 and X issues w/ executables and JavaHelp

Richard wrote:
Quote
This solution is sort of hiddened within the newgroup should I
post a FINAL SOLUTION thread?
I don't think that's necessary. The newsgroup is archived by Google and
other search engines, so it should be easy to find with a search.
--
Gillmer J. Derge (TeamB)