Google Групи більше не підтримують нові дописи або підписки Usenet. Наявний контент можна переглядати.

Setting an Application's Entry Point

5 переглядів
Перейти до першого непрочитаного повідомлення

mathieu

не прочитано,
29 груд. 2008 р., 06:24:0529.12.08
Кому:
Hi there

I am reading:

http://java.sun.com/docs/books/tutorial/deployment/jar/appman.html

But I still do not understand how to write my Manifest.txt file. In
the end I am getting the following jar file:

$ jar tvf /usr/lib/DICOMscope.jar | grep DICOMscope.class
7272 Mon Dec 29 12:17:44 CET 2008 DICOMscope/DICOMscope/
DICOMscope.class

$ cat DICOMscope.java
package DICOMscope
...
public class DICOMscope extends JFrame implements MainListener
{
public static void main (String[] args)
{
}
}

Compilation line:

$ javac -classpath . -d ../DICOMscope DICOMscope.java
$ cd ../
$ jar cfm DICOMscope.jar Manifest.txt DICOMscope/

How do I say the main function is in class DICOMscope (I do not
understand why my jar file has two levels of DICOMscope).

Thanks.

RedGrittyBrick

не прочитано,
29 груд. 2008 р., 06:53:0929.12.08
Кому:

Sigh!

-----------------------------------------------------
C:\temp>mkdir com

C:\temp>cd com

C:\temp\com>mkdir example

C:\temp\com>cd example

C:\temp\com\example>mkdir dicomscope

C:\temp\com\example>cd dicomscope

C:\temp\com\example\dicomscope>edit DICOMscope.java

C:\temp\com\example\dicomscope>type DICOMscope.java
package com.example.dicomscope;

class DICOMscope {
public static void main(String[] args) {
System.out.println("Hello from DICOMscope");
}
}

C:\temp\com\example\dicomscope>javac DICOMscope.java

C:\temp\com\example\dicomscope>dir
Volume in drive C is OS
Volume Serial Number is 50F9-F19C

Directory of C:\temp\com\example\dicomscope

29/12/2008 11:42 <DIR> .
29/12/2008 11:42 <DIR> ..
29/12/2008 11:42 458 DICOMscope.class
29/12/2008 11:42 157 DICOMscope.java
2 File(s) 615 bytes
2 Dir(s) 48,488,181,760 bytes free

C:\temp\com\example\dicomscope>cd ..\..

C:\temp\com>cd ..

C:\temp>java com.example.dicomscope.DICOMscope
Hello from DICOMscope

C:\temp>edit dicomscope.manifest

C:\temp>type dicomscope.manifest
Main-Class: com.example.dicomscope.DICOMscope

C:\temp>jar cfm DICOMscope.jar dicomscope.manifest com\example\dicomscope

C:\temp>jar tvf DICOMscope.jar
0 Mon Dec 29 11:49:00 GMT 2008 META-INF/
118 Mon Dec 29 11:49:00 GMT 2008 META-INF/MANIFEST.MF
0 Mon Dec 29 11:42:38 GMT 2008 com/example/dicomscope/
458 Mon Dec 29 11:42:38 GMT 2008 com/example/dicomscope/DICOMscope.class
157 Mon Dec 29 11:42:02 GMT 2008 com/example/dicomscope/DICOMscope.java

C:\temp>java -jar DICOMscope.jar
Hello from DICOMscope
---------------------------------------------------------------

Watch out for line-wrap in the first jar command and output of the second.

--
RGB

mathieu

не прочитано,
29 груд. 2008 р., 08:09:2729.12.08
Кому:
On Dec 29, 12:53 pm, RedGrittyBrick <RedGrittyBr...@spamweary.invalid>
wrote:

No... I still do not get it...

$ cat Manifest.txt
Main-Class: DICOMscope.DICOMscope.DICOMscope

$ java -jar /usr/lib/DICOMscope.jar
Exception in thread "main" java.lang.NoClassDefFoundError: DICOMscope/
DICOMscope/DICOMscope (wrong name: DICOMscope/DICOMscope)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass
(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:
260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:
276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:
319)


$ jar xvf /usr/lib/DICOMscope.jar | grep "DICOMscope\.class"
inflated: DICOMscope/DICOMscope/DICOMscope.class

Ewald Ertl

не прочитано,
29 груд. 2008 р., 09:18:4029.12.08
Кому:
Hi,

I've not used the manifest, but reading the exception and your
manifest file as you wrote:

In DICOMscope.java, you're package statement lists DICOMscope and not
DICOMscope.DICOMscope,
as you request in the manifest file.

I think this is could be the problem.

HTH
Ewald

Lew

не прочитано,
29 груд. 2008 р., 10:54:3529.12.08
Кому:
mathieu wrote:
>>>  I am reading:
>
>>>  http://java.sun.com/docs/books/tutorial/deployment/jar/appman.html
>
>>>   But I still do not understand how to write my Manifest.txt file. In
>>> the end I am getting the following jar file:

Maybe because the file isn't called "Manifest.txt" but "MANIFEST.MF".

Read:
<http://java.sun.com/docs/books/tutorial/deployment/jar/
manifestindex.html>

--
Lew

Lew

не прочитано,
29 груд. 2008 р., 11:15:2429.12.08
Кому:
Ewald Ertl wrote:
> I've not used the manifest, but reading the exception and your
> manifest file as you wrote:
>
> In DICOMscope.java, you're package statement lists DICOMscope and not
> DICOMscope.DICOMscope,
> as you request in the manifest file.
>
> I think this is could be the problem.

In addition to what Ewald said, it is conventional to name packages
with lower-case letters only, thus making it easier to distinguish
them from class names.

In another thread a poster provided a link to the tutorial on
packages. It is important to understand how to specify and use
packages in Java if one is to do any programming in it whatsoever.

RedGrittyBrick's post shows in detail how to compile and JAR a class
into the correct location for its package. But really, the tutorial
is the place to start.

--
Lew


Arne Vajhøj

не прочитано,
29 груд. 2008 р., 11:33:5529.12.08
Кому:

The filename does not matter - he can call it foo.bar and
the jar utility will store it as MANIFEST.MF.

Arne

Lew

не прочитано,
29 груд. 2008 р., 13:26:1629.12.08
Кому:
mathieu wrote:
>>>  I am reading:
>
>>>  http://java.sun.com/docs/books/tutorial/deployment/jar/appman.html
>
>>>   But I still do not understand how to write my Manifest.txt file. In
>>> the end I am getting the following jar file:


Lew wrote:
> Maybe because the file isn't called "Manifest.txt" but "MANIFEST.MF".

This is totally irrelevant. The 'jar' command should do the right
thing with any named input file for the manifest, creating META-INF/
MANIFEST.MF as required. Sorry about that.

> Read:
<http://java.sun.com/docs/books/tutorial/deployment/jar/
manifestindex.html>

This is totally right.

<http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html#JAR
%20Manifest>
<http://java.sun.com/javase/6/docs/technotes/tools/solaris/jar.html>
<http://java.sun.com/javase/6/docs/technotes/tools/windows/jar.html>
<http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html>
tell more.

--
Lew

Roedy Green

не прочитано,
30 груд. 2008 р., 03:56:0230.12.08
Кому:
On Mon, 29 Dec 2008 03:24:05 -0800 (PST), mathieu
<mathieu....@gmail.com> wrote, quoted or indirectly quoted
someone who said :

>
>How do I say the main function is in class DICOMscope (I do not
>understand why my jar file has two levels of DICOMscope).

Normally you let ANT create the manifests for you.

See http://mindprod.com/jgloss/ant.html
see http://mindprod.com/jgloss/jar.html#MANIFEST
--
Roedy Green Canadian Mind Products
http://mindprod.com
PM Steven Harper is fixated on the costs of implementing Kyoto, estimated as high as 1% of GDP.
However, he refuses to consider the costs of not implementing Kyoto which the
famous economist Nicholas Stern estimated at 5 to 20% of GDP

mathieu

не прочитано,
30 груд. 2008 р., 04:25:1430.12.08
Кому:
On Dec 29, 5:15 pm, Lew <l...@lewscanon.com> wrote:

> Ewald Ertl wrote:
> RedGrittyBrick's post shows in detail how to compile and JAR a class
> into the correct location for its package. But really, the tutorial
> is the place to start.

Indeed rereading it I finally found the right combo. I have packaged
my very first jar: dicomscope !

Ref:
http://svn.debian.org/viewsvn/debian-med/trunk/packages/dicomscope/trunk/debian/

Working directory for javac is actually very important. Calling the
file Manifest.txt is perfectly fine (at least for me). And sun-java
does not support "default package" as mentionned earlier (gcc-java
does however).


Thanks everybody !

Andrew Thompson

не прочитано,
30 груд. 2008 р., 05:00:2330.12.08
Кому:
On Dec 30, 8:25 pm, mathieu <mathieu.malate...@gmail.com> wrote:

> ...I have packaged


> my very first jar: dicomscope !

Congrats!

>... Calling the


> file Manifest.txt is perfectly fine (at least for me).

Wish I had 1$ for every time I heard "Works fine for me" ..and 10$ for
every time that same thing came back to bite the developer on the
a**. ;-)

--
Andrew Thompson
http://pscode.org/

Roedy Green

не прочитано,
30 груд. 2008 р., 09:57:1730.12.08
Кому:
On Mon, 29 Dec 2008 06:18:40 -0800 (PST), Ewald Ertl
<ewald...@gmail.com> wrote, quoted or indirectly quoted someone who
said :

>In DICOMscope.java, you're package statement lists DICOMscope and not


>DICOMscope.DICOMscope,
>as you request in the manifest file.

If you following the naming convention of all lower case for package
names and camel case for class names, that sort of error will tend to
jump out at you.

0 нових повідомлень