Gentoo Archives: gentoo-user

From: "Arttu V." <arttuv69@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] ebuild help: java main class?
Date: Sun, 25 Oct 2009 00:47:16
Message-Id: 4AE3A011.4030309@gmail.com
In Reply to: [gentoo-user] ebuild help: java main class? by Grant
1 Grant wrote:
2 > I'm trying to fix up the JAlbum ebuild:
3 >
4 > http://bugs.gentoo.org/show_bug.cgi?id=128356
5 >
6 > and get it to use java-pkg-2. Here's what I have so far:
7 >
8 > inherit java-pkg-2 eutils
9 >
10 > S="${WORKDIR}/Jalbum"
11 > DESCRIPTION="Web photo album generator"
12 > HOMEPAGE="http://jalbum.net/"
13 > SRC_URI="http://jalbum.net/download/Jalbum${PV}.zip"
14 >
15 > LICENSE="as-is"
16 > SLOT="0"
17 > KEYWORDS="x86"
18 > IUSE=""
19 >
20 > DEPEND=">=virtual/jre-1.5"
21 > RDEPEND="${DEPEND}"
22 >
23 > src_install() {
24 > java-pkg_dojar JAlbum.jar
25 > java-pkg_dolauncher jalbum \
26 > --jar JAlbum.jar \
27 > --java_args -Xmx400M
28 >
29 > local dest=/usr/lib/${PN}
30 > dodir ${dest}
31 > cp -R ${S}/* ${D}/${dest} || die "Install failed"
32 >
33 > doicon ${FILESDIR}/Jalbum-icon.png
34 > make_desktop_entry ${PN}
35 > }
36 >
37 > It executes just fine, but I get:
38 >
39 > $ jalbum
40 > Error: se.datadosen.jalbum.JAlbum
41 > java.lang.ClassNotFoundException: se.datadosen.jalbum.JAlbum
42 > at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
43 > at java.security.AccessController.doPrivileged(Native Method)
44 > at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
45 > at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
46 > at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
47 > at se.datadosen.jalbum.Main.main(Main.java:23)
48 >
49 > I was told I need to define the main class with --main. Does anyone
50 > know how to determine what the main class should be?
51
52
53 No, it has clearly already loaded at least one class (last line of that
54 stack trace reveals this), and is looking for some others needed by that
55 class -- but the classloader fails to find them. JAlbum probably also
56 has a Main-Class header defined in the jar's manifest, so this is likely
57 to be just another classpath-related issue.
58
59 But the ebuild you're pushing ... I think it would need some serious
60 work for the installation part. I think it installs files in all wrong
61 places, and thus Gentoo's Generation 2 java system cannot automatically
62 add them to classpath.
63
64 There is some advice on the issue in section 3, the Filesystem layout
65 over here:
66
67 http://www.gentoo.org/proj/en/java/java-devel.xml
68
69 After trudging through that you might understand why Gentoo Java team
70 has constantly several dev positions advertised on "help wanted". Some
71 of Java's ways don't mix that well with Gentoo's approaches, especially
72 with compiling and packaging (installations).
73
74 If you are in a hurry of some sort, you might just try taking the jar,
75 unpacking it into a subdir under your homedir, cd'ing in, and trying
76 something like "CLASSPATH=.:${CLASSPATH} foo.sh". With a little luck it
77 might work as such, without the pain of making a proper ebuild for it.
78
79 --
80 Arttu V.

Replies

Subject Author
Re: [gentoo-user] ebuild help: java main class? Grant <emailgrant@×××××.com>