Gentoo Archives: gentoo-user

From: Grant <emailgrant@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] ebuild help: java main class?
Date: Sat, 24 Oct 2009 21:52:58
Message-Id: 49bf44f10910241452s3520e9dfnc946ee28f361dcc0@mail.gmail.com
In Reply to: Re: [gentoo-user] ebuild help: java main class? by Alan McKinnon
1 >> >> I'm trying to fix up the JAlbum ebuild:
2 >> >>
3 >> >> http://bugs.gentoo.org/show_bug.cgi?id=128356
4 >> >>
5 >> >> and get it to use java-pkg-2.  Here's what I have so far:
6 >> >>
7 >> >> inherit java-pkg-2 eutils
8 >> >>
9 >> >> S="${WORKDIR}/Jalbum"
10 >> >> DESCRIPTION="Web photo album generator"
11 >> >> HOMEPAGE="http://jalbum.net/"
12 >> >> SRC_URI="http://jalbum.net/download/Jalbum${PV}.zip"
13 >> >>
14 >> >> LICENSE="as-is"
15 >> >> SLOT="0"
16 >> >> KEYWORDS="x86"
17 >> >> IUSE=""
18 >> >>
19 >> >> DEPEND=">=virtual/jre-1.5"
20 >> >> RDEPEND="${DEPEND}"
21 >> >>
22 >> >> src_install() {
23 >> >>     java-pkg_dojar JAlbum.jar
24 >> >>     java-pkg_dolauncher jalbum \
25 >> >>         --jar JAlbum.jar \
26 >> >>         --java_args -Xmx400M
27 >> >>
28 >> >>     local dest=/usr/lib/${PN}
29 >> >>     dodir ${dest}
30 >> >>     cp -R ${S}/* ${D}/${dest} || die "Install failed"
31 >> >>
32 >> >>     doicon ${FILESDIR}/Jalbum-icon.png
33 >> >>     make_desktop_entry ${PN}
34 >> >> }
35 >> >>
36 >> >> It executes just fine, but I get:
37 >> >>
38 >> >> $ jalbum
39 >> >> Error: se.datadosen.jalbum.JAlbum
40 >> >> java.lang.ClassNotFoundException: se.datadosen.jalbum.JAlbum
41 >> >>       at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
42 >> >>       at java.security.AccessController.doPrivileged(Native Method)
43 >> >>       at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
44 >> >>       at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
45 >> >>       at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
46 >> >>       at se.datadosen.jalbum.Main.main(Main.java:23)
47 >> >>
48 >> >> I was told I need to define the main class with --main.  Does anyone
49 >> >> know how to determine what the main class should be?
50 >> >
51 >> > What's the line normally used to launch the app at runtime? That,
52 >> > together with CLASSPATH will tell you what class should be executed as
53 >> > main()
54 >>
55 >> There is a file called startjalbum.sh which is supposed to be used to
56 >> start the program.  It contains:
57 >>
58 >> #!/bin/sh
59 >> java -Xmx400M -jar JAlbum.jar
60 >>
61 >> Does that tell you anything?
62 >
63 > Yes, it does. There's a file called JAlbum.jar which contains the app, and
64 > it's location is visible to the script. There's no path so I'm assuming the
65 > file is in the current directory.
66 >
67 > A .jar is just a special kind of zip file (much like OOo files are). What's
68 > inside it?
69
70 # unzip JAlbum.jar
71 Archive: JAlbum.jar
72 creating: META-INF/
73 inflating: META-INF/MANIFEST.MF
74 creating: se/
75 creating: se/datadosen/
76 creating: se/datadosen/jalbum/
77 inflating: se/datadosen/jalbum/AlbumBeanEvent.class
78 inflating: se/datadosen/jalbum/AlbumBeanListener.class
79 inflating: se/datadosen/jalbum/AlbumEngine.class
80 inflating: se/datadosen/jalbum/Main$1.class
81 inflating: se/datadosen/jalbum/Main.class
82 inflating: se/datadosen/jalbum/MiniConfig.class
83 inflating: se/datadosen/jalbum/OperationAbortedException.class
84 creating: se/datadosen/tags/
85 inflating: se/datadosen/tags/ElementException.class
86
87 > p.s. I don't know how familiar you are with Java's start-up process and how it
88 > finds things and how you specify things to find. It's somewhat unusual and
89 > many traps exist for the unwary :-)
90
91 I'm completely clueless with java. Thanks a lot for your help thus far.
92
93 - Grant