Skip to main content

Best way to compile JAR files with Eclipse

12 replies [Last post]
terymas
Offline
Joined: 2007-09-03

Hi all,

Some body know, how to export a good jar file for BluRay with Eclipse.
I have a tutorial with a jar files and the source code.
When I test the original jar files, I have no issues.

But when I create a new project in Eclipse with the source, I export to jar and when I playback my BD : my BD player doesn't play the java app.

Thank you very much !
Tery Mas

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Bill Foote

Hi Tery,

In the source code repository at https://hdcookbook.dev.java.net, we
have a whole build environment set up that makes the right disc
image. It includes a JAR signing tool, a tool to create the needed
BDJO file, and much more.

You do have to set up a couple of environment variables - this is all
explained in the repository. It works with ant. There's also a
NetBeans project file set up already. With the ant build script that's
already there, it should be pretty simple to set up a project file for
other IDEs.

Cheers,

Bill

bd-j-dev@mobileandembedded.org wrote:
> Hi all,
>
> Some body know, how to export a good jar file for BluRay with Eclipse.
> I have a tutorial with a jar files and the source code.
> When I test the original jar files, I have no issues.
>
> But when I create a new project in Eclipse with the source, I export to jar and when I playback my BD : my BD player doesn't play the java app.
>
> Thank you very much !
> Tery Mas
> [Message sent by forum member 'terymas' (terymas)]
>
> http://forums.java.net/jive/thread.jspa?messageID=253461
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: bd-j-dev-unsubscribe@hdcookbook.dev.java.net
> For additional commands, e-mail: bd-j-dev-help@hdcookbook.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: bd-j-dev-unsubscribe@hdcookbook.dev.java.net
For additional commands, e-mail: bd-j-dev-help@hdcookbook.dev.java.net

terymas
Offline
Joined: 2007-09-03

Hi Bill,

In fact my authoring software, sign and create BDJO and certificate.

But ! I have download your JAR siging tool.
I have found how to use it with ANT script command and I compile to .jar file with.

here my console window (in Eclipe) :

Buildfile: C:\Program Files\Java\jdk1.5.0_14\lib\bdsigner\make\build.xml
prepare:
[mkdir] Created dir: H:\_Java\Working Folder Eclipse\Sample\build\classes
compile:
[javac] Compiling 1 source file to H:\_Java\Working Folder Eclipse\Sample\build\classes
deploy:
[jar] Building jar: H:\_Java\Working Folder Eclipse\Sample\build\bdsigner.jar
all:
BUILD SUCCESSFUL
Total time: 1 second

Now I have my "bdsigner.jar"
I don't unterstand, how to use BDCertGenerator.java
I have read the "Read Me" but I don't understand...
/**
* A class that wraps around jarsigner and keytool to perform bd-j required
* certificate generation.
*
* The steps involved in generating a new certificate are:
* 1) Generate an application certificate.
* 2) Generate a root certificate.
* 3) Generate a certificate signing request (CSR) based on (1).
* 4) Issue a certificate based on the CSR from (3), using the alias
* for root certificate from (2).
* 5) Import the certificate back into the store issued at (4) as
* the root cert signed application certificate generated at (1).
*
* BDCertGenerator syntax is :
* BDCertGenerator [-debug] 8-digit-hex-organization-ID
*
* Example: java -cp $BDSIGNER_HOME/build/bdsigner.jar:$JDK_HOME/lib/tools.jar:$BDSIGNER_HOME/resource/bcprov-jdk15-137.jar net.java.bd.tools.bdsigner.BDCertGenerator 56789abc
*
* Make sure to put bdsigner.jar before tools.jar in the jdk distribution
* for the jre classpath so that the modified version of the sun.security.*
* classes in BDCertGenerator this respository are used at the runtime.
* bdprov-jdk15-137.jar is a bouncycastle distribution; a copy can be bound
* at "resources" dir.
*
*/

Can you explain to me, step by step, how to use it ? Please : )

Best Regards,
Tery

bjoern_minkmar
Offline
Joined: 2007-06-11

hi terymas,

you need the following three jar-files to get things working:

1) the bdsigner.jar which you have successfully created
2) the tools.jar which you can find in path\to\your\jdk\lib\
3) the bcprov-jdk15-137.jar (Bouncy Castle Crypto API) which you can find in hdcookbook\tools\bdsigner\resource

if you have all these jar-files and you know the path where to find them on your harddrive, then you can open a console and type the following command:

java -cp PATH\2\bdsigner.jar:PATH\2\tools.jar:PATH\2\bcprov-jdk15-137.jar net.java.bd.tools.bdsigner.BDCertGenerator ORG-ID JAR-FILE

make sure to keep the order (bdsigner.jar, tools.jar and then bcprov-jdk15-137.jar) and replace the following:

- PATH\2 with the appropriate path,
- ORG-ID with the id of your organisation (default is 56789abc) and
- JAR-FILE with the name of your jar-file (probably 00000.jar)

if you run this example on Windows please be aware that the delimiter for the classpath
is ";", so you would want to replace ":" with ";" in the example above.

cheers,
björn

terymas
Offline
Joined: 2007-09-03

Hi Björn,

thank you very much, I have understand now !

Well, I'm on Windows, I launch my console and I type :

java -cp H:\_Java\Working Folder Eclipse\Sample\build\bdsigner.jar;C:\Program Files\Java\jdk1.5.0_14\lib\tools.jar;C:\Program Files\Java\jdk1.5.0_14\lib\bdsigner\resource\bcprov-jdk15-137.jar net.java.bd.tools.bdsigner.BDCertGenerator 56789abc 00000.jar

And I have this error message :
Exception in thread "main" java.lang.NoClassDefFoundError: Folder

Do you know, where is my issue ?

Regards,
Tery

bjoern_minkmar
Offline
Joined: 2007-06-11

hi tery,

it is the name of your folder that causes the error.

"Working Folder Eclipse" contains spaces, that is why the compiler is seaching for
a class Folder in the directory H:_Java\Working, which does not exist and therefore can
not be found.

you can either rename the folder, so that it contains no more spaces or you can put braces around the classpath statement:

java -cp "H:\Java\Working Folder Eclipse\Sample\build\bdsigner.jar";"...";"..." net.java.bd.tools.bdsigner.BDCertGenerator 56789abc 00000.jar

cheers,
björn

terymas
Offline
Joined: 2007-09-03

Hi Björn,

To be sure, I put the files on "C"
And I type like that :

java -cp "C:\build\bdsigner.jar";"C:\Program Files\Java\jdk1.5.0_14\lib\tools.jar";"C:\bdsigner\resource\bcprov-jdk15-137.jar" net.java.bd.tools.bdsigner.BDCertGenerator 56789abc 00000.jar

Now I have a new issue :
Exception in thread "main" java.lang.NoClassDefFoundError: net/java/bd/tools/bdsigner/BDCertGenerator

Regards,
Tery

chihiro_saito
Offline
Joined: 2006-11-08

Hi Tery, Bjorn,

> java -cp "C:\build\bdsigner.jar";"C:\Program Files\Java\jdk1.5.0_14\lib\tools.jar";"C:\bdsigner\resource\bcprov-jdk15-137.jar" net.java.bd.tools.bdsigner.BDCertGenerator 56789abc 00000.jar

There seems to be an error in the README. The main app's name is "net.java.bd.tools.bdsigner.BDSigner" and not BDCertGenerator. Could you try with

> java -cp "C:\build\bdsigner.jar";"C:\Program Files\Java\jdk1.5.0_14\lib\tools.jar";"C:\bdsigner\resource\bcprov-jdk15-137.jar" net.java.bd.tools.bdsigner.BDSigner 56789abc 00000.jar

I'll fix the README right now.

Sorry,
Chihiro

chihiro_saito
Offline
Joined: 2006-11-08

Ok, The tool's README file seemed to be pointing at BDSigner like it is supposed to be? I just updated the BDCertGenerator class header with an warning. We have a commit pending for the credentials right now which should update BDCertGenerator...

Please let us know if BDSigner doesn't work, meanwhile.

Thanks,
Chihiro

terymas
Offline
Joined: 2007-09-03

Hi Chihiro,

with BDSigner it's the same :

Exception in thread "main" java.lang.NoClassDefFoundError: net/java/bd/tools/bdsigner/BDSigner

Regards,
Tery

chihiro_saito
Offline
Joined: 2006-11-08

Hi Tery,

Perhaps you can do this step by step.

Does

> java -cp "c:\\bdsigner.jar" net.java.bd.tools.bdsigner.BDSigner

work (no java.lang.NoClassDefFoundError), for a start?

Thanks,
Chihiro

terymas
Offline
Joined: 2007-09-03

Hi Chihiro,

I try : java -cp "C:\build\bdsigner.jar" net.java.bd.tools.bdsigner.BDSigner

Exception in thread "main" java.lang.NoClassDefFoundError: net/java/bd/tools/bdsigner/BDSigner

If I try : java -cp "C:\build\bdsigner.jar"

Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)

where options include:
-client to select the "client" VM
-server to select the "server" VM
-hotspot is a synonym for the "client" VM [deprecated]
The default VM is client.

-cp
-classpath
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D=
set a system property
-verbose[:class|gc|jni]
enable verbose output
-version print product version and exit
-version:
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -jre-no-restrict-search
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:
...|:]
-enableassertions[:
...|:]
enable assertions
-da[:
...|:]
-disableassertions[:
...|:]
disable assertions
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:
[=]
load native agent library
, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:
[=]
load native agent library by full pathname
-javaagent:[=]
load Java programming language agent, see java.lang.instrument

And If I try : "C:\Program Files\Java\jdk1.5.0_14\lib\tools.jar"
or "C:\bdsigner\resource\bcprov-jdk15-137.jar"

Popup windows Java Virtual Machine Launcher : Failed to load Main-Class manifest attribute form

C:\Program Files\Java\jdk1.5.0_14\lib\tools.jar

or

C:\bdsigner\resource\bcprov-jdk15-137.jar

I wish that will help you to show an issue.
Regards,

Tery

bjoern_minkmar
Offline
Joined: 2007-06-11

hi tery,

the exception you get says that the class that you want to use can not be found.

please check again that the bdsigner.jar is really on harddrive "C" in the "build" folder.
you could also navigate to your "build" folder via the console and check that the bdsigner.jar is in that folder. if that is the case, try the following command:

java -cp bdsigner.jar net.java.bd.tools.bdsigner.BDSigner

this should bring up the following error message:
Exception in thread "main" java.lang.NoClassDefFoundError: org/bouncycastle/jce/
provider/BouncyCastleProvider

this message would show you that the BDSigner class can now be found and that it is trying to find the BouncyCastleProvider class from the bouncy castle jar-file (bcprov-jdk15-137.jar).

if instead you still get the message that the BDSigner class can not be found, then you
should unzip the bdsigner.jar-file and check if the BDSigner class can be found in net/java/bd/tools/bdsigner.

please try these steps and then tell us what happens.

cheers,
björn