[Ibm-netrexx] setting CLASSPATH in java command line

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

[Ibm-netrexx] setting CLASSPATH in java command line

Aviatrexx
OK, I'm experimenting with different ways of invoking NetRexx, and since SUN
seems to feel that using the '-cp/-classpath' flag on java invocation is the
"preferred technique", I've been trying to get it to work.

So just how the hell do you specify such a classpath when java is installed (as
it invariably seems to be) in "C:\Program Files\Java\...".  I've tried every
combination of single and double quotes I can think of, and invariably I get:

C:\Program Files\NetRexx\bin>java -classpath .;C:\"Program Files"\Java\jdk1.6.0_
18\lib\tools.jar;C:\Program Files\NetRexx\lib\NetRexxC.jar COM.ibm.netrexx.proce
ss.NetRexxC hello
Exception in thread "main" java.lang.NoClassDefFoundError: Files\Java\jdk1/6/0_1
8\lib\tools/jar;C:\Program Files\NetRexx\lib\NetRexxC/jar COM/ibm/netrexx/proces
s/NetRexxC hello

If I EVER find the moron who thought blanks in filenames was a good idea... >:-{

-Chip-
_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Ibm-netrexx] setting CLASSPATH in java command line

alansam
Try:

C:\PROGRA~1 (or whatever it happens to be on your sysrem.  dir /x C:\Pro* should tell you.)

Personally I never allow the Java installer to just dump stuff in "Program Files" for that very reason, I force it to use C:\Java.  I can see no valid reason for allowing spaces in file and directory names, particularly important ones like system service repositories.

Alan.

On 18 February 2010 10:56, Chip Davis <[hidden email]> wrote:
OK, I'm experimenting with different ways of invoking NetRexx, and since SUN seems to feel that using the '-cp/-classpath' flag on java invocation is the "preferred technique", I've been trying to get it to work.

So just how the hell do you specify such a classpath when java is installed (as it invariably seems to be) in "C:\Program Files\Java\...".  I've tried every combination of single and double quotes I can think of, and invariably I get:

C:\Program Files\NetRexx\bin>java -classpath .;C:\"Program Files"\Java\jdk1.6.0_
18\lib\tools.jar;C:\Program Files\NetRexx\lib\NetRexxC.jar COM.ibm.netrexx.proce
ss.NetRexxC hello
Exception in thread "main" java.lang.NoClassDefFoundError: Files\Java\jdk1/6/0_1
8\lib\tools/jar;C:\Program Files\NetRexx\lib\NetRexxC/jar COM/ibm/netrexx/proces
s/NetRexxC hello

If I EVER find the moron who thought blanks in filenames was a good idea... >:-{

-Chip-
_______________________________________________
Ibm-netrexx mailing list
[hidden email]




--
Needs more cow-bell!

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Alan

--
Needs more cowbell.
Reply | Threaded
Open this post in threaded view
|

Re: [Ibm-netrexx] setting CLASSPATH in java command line

Tom Maynard
In reply to this post by Aviatrexx
Chip Davis wrote:
> So just how the hell do you specify such a classpath when java is
> installed (as it invariably seems to be) in "C:\Program
> Files\Java\...".  I've tried every combination of single and double
> quotes I can think of, and invariably I get:
>
I put quotes (single or double) around the entire pathspec, not just
around the portions with embedded blanks:

    -classpath .;"C:\Program
Files\Java\jdk1.6.0_18\lib\tools.jar";"C:\Program
Files\NetRexx\lib\NetRexxC.jar"

I suppose it might also work with the whole string in quotes, but I
didn't try.

Tom.

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Ibm-netrexx] setting CLASSPATH in java command line

Aviatrexx
In reply to this post by alansam
Thanks, Alan!  That did the trick, but man, is it FUGLY...

That was probably common knowledge for someone who likes Windows enough to
actually study it... :-/

That also means that it is going to be a challenge to dynamically determine that
8-char name in a .bat file or installation routine.  And given the number of
folks who have trouble getting NetRexx to run using the default directories,
environment variables, .bat files, etc. I'm not sanguine that the '-cp' flag is
going to be a viable approach.

-Chip-

On 2/18/10 19:16 Alan Sampson said:

> Try:
>
> C:\PROGRA~1 (or whatever it happens to be on your sysrem.  dir /x
> C:\Pro* should tell you.)
>
> Personally I never allow the Java installer to just dump stuff in
> "Program Files" for that very reason, I force it to use C:\Java.  I can
> see no valid reason for allowing spaces in file and directory names,
> particularly important ones like system service repositories.
>
> Alan.
>
> On 18 February 2010 10:56, Chip Davis <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     OK, I'm experimenting with different ways of invoking NetRexx, and
>     since SUN seems to feel that using the '-cp/-classpath' flag on java
>     invocation is the "preferred technique", I've been trying to get it
>     to work.
>
>     So just how the hell do you specify such a classpath when java is
>     installed (as it invariably seems to be) in "C:\Program
>     Files\Java\...".  I've tried every combination of single and double
>     quotes I can think of, and invariably I get:
>
>     C:\Program Files\NetRexx\bin>java -classpath .;C:\"Program
>     Files"\Java\jdk1.6.0_
>     18\lib\tools.jar;C:\Program Files\NetRexx\lib\NetRexxC.jar
>     COM.ibm.netrexx.proce
>     ss.NetRexxC hello
>     Exception in thread "main" java.lang.NoClassDefFoundError:
>     Files\Java\jdk1/6/0_1
>     8\lib\tools/jar;C:\Program Files\NetRexx\lib\NetRexxC/jar
>     COM/ibm/netrexx/proces
>     s/NetRexxC hello
>
>     If I EVER find the moron who thought blanks in filenames was a good
>     idea... >:-{
>
>     -Chip-
>     _______________________________________________
>     Ibm-netrexx mailing list
>     [hidden email] <mailto:[hidden email]>
>
>
>
>
> --
> Needs more cow-bell!
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
>
_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [Ibm-netrexx] setting CLASSPATH in java command line

Mike Cowlishaw
 
Fairly sure that the Windows shell will pass on a string like this:

   foo bar "a b c" d e f "and whatever"

as 7 'words' to the application: quoted strings get passed on as one word
(without the quotes).  And in all fairness, not really a Windows problem ..
basic fault is in the C interface .. main program gets an array of 'words'
instead of a string.   So all sorts of problems .. cannot pass on two blanks
to a windows command; maybe true in some *ix, too.   Years behind VM/SP2 of
1982 <sigh>.

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Ibm-netrexx] setting CLASSPATH in java command line

Kermit Kiser
In reply to this post by Aviatrexx
Clearly someone had a "brain-fart" when classpath was designed.

Apparently you can put quotes around the entire classpath or any
complete subpath containing blanks. Blanks not in quotes break the
classpath as will a double semicolon. The rules for the CLASSPATH
variable are slightly different.

Lots of good tips about classpaths are here:

http://mindprod.com/jgloss/classpath.html

-- Kermit

Chip Davis wrote:

> Thanks, Alan!  That did the trick, but man, is it FUGLY...
>
> That was probably common knowledge for someone who likes Windows
> enough to actually study it... :-/
>
> That also means that it is going to be a challenge to dynamically
> determine that 8-char name in a .bat file or installation routine.  
> And given the number of folks who have trouble getting NetRexx to run
> using the default directories, environment variables, .bat files, etc.
> I'm not sanguine that the '-cp' flag is going to be a viable approach.
>
> -Chip-
>
> On 2/18/10 19:16 Alan Sampson said:
>> Try:
>>
>> C:\PROGRA~1 (or whatever it happens to be on your sysrem.  dir /x
>> C:\Pro* should tell you.)
>>
>> Personally I never allow the Java installer to just dump stuff in
>> "Program Files" for that very reason, I force it to use C:\Java.  I
>> can see no valid reason for allowing spaces in file and directory
>> names, particularly important ones like system service repositories.
>>
>> Alan.
>>
>> On 18 February 2010 10:56, Chip Davis <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>>     OK, I'm experimenting with different ways of invoking NetRexx, and
>>     since SUN seems to feel that using the '-cp/-classpath' flag on java
>>     invocation is the "preferred technique", I've been trying to get it
>>     to work.
>>
>>     So just how the hell do you specify such a classpath when java is
>>     installed (as it invariably seems to be) in "C:\Program
>>     Files\Java\...".  I've tried every combination of single and double
>>     quotes I can think of, and invariably I get:
>>
>>     C:\Program Files\NetRexx\bin>java -classpath .;C:\"Program
>>     Files"\Java\jdk1.6.0_
>>     18\lib\tools.jar;C:\Program Files\NetRexx\lib\NetRexxC.jar
>>     COM.ibm.netrexx.proce
>>     ss.NetRexxC hello
>>     Exception in thread "main" java.lang.NoClassDefFoundError:
>>     Files\Java\jdk1/6/0_1
>>     8\lib\tools/jar;C:\Program Files\NetRexx\lib\NetRexxC/jar
>>     COM/ibm/netrexx/proces
>>     s/NetRexxC hello
>>
>>     If I EVER find the moron who thought blanks in filenames was a good
>>     idea... >:-{
>>
>>     -Chip-
>>     _______________________________________________
>>     Ibm-netrexx mailing list
>>     [hidden email] <mailto:[hidden email]>
>>
>>
>>
>>
>> --
>> Needs more cow-bell!
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Ibm-netrexx mailing list
>> [hidden email]
>>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
>
>
>
_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Ibm-netrexx] setting CLASSPATH in java command line

Aviatrexx
In reply to this post by Tom Maynard
Thanks, Tom!  That did the trick too, and is certainly going to be easier to
automate than trying to find the 8-char directory name.

That was a configuration that didn't fall into the "that I could think of"
category.  I did try putting the entire path string in quotes (didn't like
"'.;") and the entire flag in quotes (didn't like "'-cp" and thus thought the
path was a filename).

I think I can work with this.

-Chip-

On 2/18/10 19:22 Tom Maynard said:

> Chip Davis wrote:
>> So just how the hell do you specify such a classpath when java is
>> installed (as it invariably seems to be) in "C:\Program
>> Files\Java\...".  I've tried every combination of single and double
>> quotes I can think of, and invariably I get:
>>
> I put quotes (single or double) around the entire pathspec, not just
> around the portions with embedded blanks:
>
>    -classpath .;"C:\Program
> Files\Java\jdk1.6.0_18\lib\tools.jar";"C:\Program
> Files\NetRexx\lib\NetRexxC.jar"
>
> I suppose it might also work with the whole string in quotes, but I
> didn't try.
>
> Tom.
>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
>
>
_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Ibm-netrexx] setting CLASSPATH in java command line

Fernando Cassia-2


On Thu, Feb 18, 2010 at 5:35 PM, Chip Davis <[hidden email]> wrote:
Thanks, Tom!  That did the trick too, and is certainly going to be easier to automate than trying to find the 8-char directory name.

At the risk of repeating myself... a properly packaged Java application should be deployed as a single .Jar file and it should run without making any changes to the classpath.

See the third reply:
http://stackoverflow.com/questions/219585/setting-multiple-jars-in-java-classpath

-------------------------------------------------------------------------------------------------------

We get around this problem by deploying a main jar file myapp.jar which contains a manifest (Manifest.mf) file specifying a classpath with the other required jars, which are then deployed alongside it. In this case, you only need to declare java -classpath myapp.jar when running the code.

So if you deploy the main jar into some directory, and then put the dependent jars into a lib folder beneath that, the manifest looks like:

Manifest-Version: 1.0
Implementation-Title: myapp
Implementation-Version: 1.0.1
Class-Path: lib/dep1.jar lib/dep2.jar

NB: this is platform-independent - we can use the same jars to launch on a UNIX server or on a Windows PC.

-------------------------------------------------------------------------------------------------------

FC


_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [Ibm-netrexx] setting CLASSPATH in java command line

Aviatrexx
If I understand you correctly FC, what you are describing is appropriate for an
application package of pre-compiled Java classes.  In the case of NetRexx, the
"application" (NetRexxC.jar) is creating new Java classes all over the place.
In this situation, I would consider it a "meta-package".

I see no way to apply the Manifest technique without adding a lot of constraints
and overhead to the process of transforming a NetRexx program into a class file,
or running it interactively.

But I could be (and am often) wrong, so I'm sure someone will enlighten me.

-Chip-

On 2/18/10 21:50 Fernando Cassia said:

>
>
> On Thu, Feb 18, 2010 at 5:35 PM, Chip Davis <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Thanks, Tom!  That did the trick too, and is certainly going to be
>     easier to automate than trying to find the 8-char directory name.
>
>
> At the risk of repeating myself... a properly packaged Java application
> should be deployed as a single .Jar file and it should run without
> making any changes to the classpath.
>
> See the third reply:
> http://stackoverflow.com/questions/219585/setting-multiple-jars-in-java-classpath
>
> -------------------------------------------------------------------------------------------------------
>
> We get around this problem by deploying a *main* jar file |myapp.jar|
> which contains a *manifest* (|Manifest.mf|) file specifying a classpath
> with the other required jars, which are then deployed alongside it. In
> this case, you only need to declare |java -classpath myapp.jar| when
> running the code.
>
> So if you deploy the main |jar| into some directory, and then put the
> dependent jars into a |lib| folder beneath that, the manifest looks like:
>
> |Manifest-Version: 1.0
>
> Implementation-Title: myapp
> Implementation-Version: 1.0.1
>
> Class-Path: lib/dep1.jar lib/dep2.jar
>
> |
>
> NB: this is platform-independent - we can use the same jars to launch on
> a UNIX server or on a Windows PC.
>
> -------------------------------------------------------------------------------------------------------
>
> FC
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
>
_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: setting CLASSPATH in java command line

David Requena
In reply to this post by Fernando Cassia-2
Fernando,

I agree the '-jar' jvm switch is the way to go for your run of the mill app with a single entry point, which the NetRexx processor is not by any means.

I also fail to see why all the fuzz about the classpath thing. As soon as your projects start to grwo bigger you're likely to be including all kinds of third party libraries, thus being forced to wrestle with classpath in one way or another. Here is where IDE's and tools like maven, ant or even the classic make come into play.

While including needed support jar files inside your distribution package (zip, tgz, or whatever) is in my view a good idea, I don't see the point in merging all the stuff *into a sigle jar* as was initially proposed in this thread.
---
Saludos / Kind regards.
David Requena

El 18/02/2010 22:50, Fernando Cassia escribió:


On Thu, Feb 18, 2010 at 5:35 PM, Chip Davis <[hidden email]> wrote:
Thanks, Tom!  That did the trick too, and is certainly going to be easier to automate than trying to find the 8-char directory name.

At the risk of repeating myself... a properly packaged Java application should be deployed as a single .Jar file and it should run without making any changes to the classpath.

See the third reply:
http://stackoverflow.com/questions/219585/setting-multiple-jars-in-java-classpath

-------------------------------------------------------------------------------------------------------

We get around this problem by deploying a main jar file myapp.jar which contains a manifest (Manifest.mf) file specifying a classpath with the other required jars, which are then deployed alongside it. In this case, you only need to declare java -classpath myapp.jar when running the code.

So if you deploy the main jar into some directory, and then put the dependent jars into a lib folder beneath that, the manifest looks like:

Manifest-Version: 1.0

Implementation-Title: myapp
Implementation-Version: 1.0.1

Class-Path: lib/dep1.jar lib/dep2.jar

NB: this is platform-independent - we can use the same jars to launch on a UNIX server or on a Windows PC.

-------------------------------------------------------------------------------------------------------

FC

_______________________________________________ Ibm-netrexx mailing list [hidden email]

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: setting CLASSPATH in java command line

Fernando Cassia-2


On Fri, Feb 19, 2010 at 7:39 AM, David Requena <[hidden email]> wrote:
Fernando,

I agree the '-jar' jvm switch is the way to go for your run of the mill app with a single entry point, which the NetRexx processor is not by any means.

Good.
 
I also fail to see why all the fuzz about the classpath thing. As soon as your projects start to grwo bigger you're likely to be including all kinds of third party libraries, thus being forced to wrestle with classpath in one way or another. Here is where IDE's and tools like maven, ant or even the classic make come into play.

Are we talking about DEVELOPING an app or DEPLOYING an app? Sorry, I lost the plot...
 

While including needed support jar files inside your distribution package (zip, tgz, or whatever) is in my view a good idea, I don't see the point in merging all the stuff *into a sigle jar* as was initially proposed in this thread.

I don´t think I was the one who asked about merging everything in a single Jar, although as you reckon, it´s a good idea.

http://java.sun.com/developer/technicalArticles/java_warehouse/single_jar/

http://blog.taragana.com/index.php/archive/apache-ant-how-to-include-multiple-jar-files-in-a-single-jar-file/

http://one-jar.sourceforge.net/

"Java developers often come to a point where they wish to deliver their application as a single Jar file. The Java Runtime Environment supports running a Jar file using the following syntax:
java -jar jarname.jar
The only requirement of the jarname.jar file is that it contains a manifest attribute with the key Main-Class a main class to run. Suppose the application entry point is the class com.mydomain.mypackage.Main. Add the following line to the META-INF/MANIFEST.MF file:
Main-Class: com.mydomain.mypackage.Main
So far so good. But, here's where the problems usually start. Any non-trivial Java application is going to rely on any number of supporting Jar files. For example, using the Apache Commons Logging capabilty to do logging an application will need to have the commons-logging.jar file on its classpath.

Most developers reasonably assume that putting such a Jar file into their own Jar file, and adding a Class-Path attribute to the META-INF/MANIFEST will do the trick:

jarname.jar
| /META-INF
| | MANIFEST.MF
| | Main-Class: com.mydomain.mypackage.Main
| | Class-Path: commons-logging.jar
| /com/mydomain/mypackage
| | Main.class
| commons-logging.jar
Unfortunately this is not the case. The Java classloader does not know how to load classes from a Jar inside a Jar. The entries on the Class-Path must be references to files outside the Jar file, defeating the goal of delivering an application in a single Jar file."
"One-JAR uses a classloader which knows how to load classes and resources from Jar files inside a Jar file. To help provide some structure to the classloading process, the One-JAR JarClassLoader looks for a main program inside a main directory in the Jar file, and looks for supporting Jar files inside a lib directory"

Hope this helps someone. Or perhaps I´m making assumptions about the way Netrexx works.

FC


_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: setting CLASSPATH in java command line

David Requena
Fernando,

My own take in that matters is that some point of equilibrium must be established.

Taken to the extreme the 'bundle all' approach takes us to what IBM is actually doing with some of their products which even bundle the jre itself. I'm sorry but I abhor the idea of loading 1.3 GB of gibberish to my pc just in order to be able to manage a DS4800 SAN cabinet!! Then again for the Notes client. Then... well, you get it.

The distinction between developing and deploying an app in this context looks moot to me. Any app developed using third party libraries will need these very same libs when deployed.

And no, I don't think putting all into one jar is a good idea. I was talking about putting them into the same distribution package (zip, tgz, etc) jointly with any readme.txt, changelog.txt, etc.

On occasion, if only a few classes from a jar are needed, and licensing allows, I'll pull them form the original jar and put into mine.

---
Saludos / Kind regards.
David Requena

El 19/02/2010 12:05, Fernando Cassia escribió:


On Fri, Feb 19, 2010 at 7:39 AM, David Requena <[hidden email]> wrote:
Fernando,

I agree the '-jar' jvm switch is the way to go for your run of the mill app with a single entry point, which the NetRexx processor is not by any means.

Good.
 
I also fail to see why all the fuzz about the classpath thing. As soon as your projects start to grwo bigger you're likely to be including all kinds of third party libraries, thus being forced to wrestle with classpath in one way or another. Here is where IDE's and tools like maven, ant or even the classic make come into play.

Are we talking about DEVELOPING an app or DEPLOYING an app? Sorry, I lost the plot...
 

While including needed support jar files inside your distribution package (zip, tgz, or whatever) is in my view a good idea, I don't see the point in merging all the stuff *into a sigle jar* as was initially proposed in this thread.

I don´t think I was the one who asked about merging everything in a single Jar, although as you reckon, it´s a good idea.

http://java.sun.com/developer/technicalArticles/java_warehouse/single_jar/

http://blog.taragana.com/index.php/archive/apache-ant-how-to-include-multiple-jar-files-in-a-single-jar-file/

http://one-jar.sourceforge.net/

"Java developers often come to a point where they wish to deliver their application as a single Jar file. The Java Runtime Environment supports running a Jar file using the following syntax:
java -jar jarname.jar
  
The only requirement of the jarname.jar file is that it contains a manifest attribute with the key Main-Class a main class to run. Suppose the application entry point is the class com.mydomain.mypackage.Main. Add the following line to the META-INF/MANIFEST.MF file:
Main-Class: com.mydomain.mypackage.Main
  
So far so good. But, here's where the problems usually start. Any non-trivial Java application is going to rely on any number of supporting Jar files. For example, using the Apache Commons Logging capabilty to do logging an application will need to have the commons-logging.jar file on its classpath.

Most developers reasonably assume that putting such a Jar file into their own Jar file, and adding a Class-Path attribute to the META-INF/MANIFEST will do the trick:

jarname.jar
| /META-INF
| | MANIFEST.MF
| |  Main-Class: com.mydomain.mypackage.Main
| |  Class-Path: commons-logging.jar
| /com/mydomain/mypackage
| | Main.class
| commons-logging.jar
  
Unfortunately this is not the case. The Java classloader does not know how to load classes from a Jar inside a Jar. The entries on the Class-Path must be references to files outside the Jar file, defeating the goal of delivering an application in a single Jar file."
"One-JAR uses a classloader which knows how to load classes and resources from Jar files inside a Jar file. To help provide some structure to the classloading process, the One-JAR JarClassLoader looks for a main program inside a main directory in the Jar file, and looks for supporting Jar files inside a lib directory"

Hope this helps someone. Or perhaps I´m making assumptions about the way Netrexx works.

FC

_______________________________________________ Ibm-netrexx mailing list [hidden email]

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: setting CLASSPATH in java command line

Thomas.Schneider.Wien
In reply to this post by Fernando Cassia-2
Hi Fernando & all,

   First, thanks Fernando, for the Syntax available in jar I have *not
been* aware of:
"Java developers often come to a point where they wish to deliver their
application as a single Jar file. The Java Runtime Environment supports
running a Jar file using the following syntax:

java -jar /jarname.jar

  Second, I do think I have been the culprit who raised this discussion :-(

But I do think, we all might be learning a bit of the various options avaliable in Java to deploy an
application (and I am talking of deployment) from this discussion...

Tom.

================================================================================
/


Fernando Cassia schrieb:

>
>
> On Fri, Feb 19, 2010 at 7:39 AM, David Requena <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     Fernando,
>
>     I agree the '-jar' jvm switch is the way to go for your run of the
>     mill app with a single entry point, which the NetRexx processor is
>     not by any means.
>
>
> Good.
>  
>
>     I also fail to see why all the fuzz about the classpath thing. As
>     soon as your projects start to grwo bigger you're likely to be
>     including all kinds of third party libraries, thus being forced to
>     wrestle with classpath in one way or another. Here is where IDE's
>     and tools like maven, ant or even the classic make come into play.
>
>
> Are we talking about DEVELOPING an app or DEPLOYING an app? Sorry, I
> lost the plot...
>  
>
>
>     While including needed support jar files inside your distribution
>     package (zip, tgz, or whatever) is in my view a good idea, I don't
>     see the point in merging all the stuff *into a sigle jar* as was
>     initially proposed in this thread.
>
>
> I don´t think I was the one who asked about merging everything in a
> single Jar, although as you reckon, it´s a good idea.
>
> http://java.sun.com/developer/technicalArticles/java_warehouse/single_jar/
>
> http://blog.taragana.com/index.php/archive/apache-ant-how-to-include-multiple-jar-files-in-a-single-jar-file/
>
> http://one-jar.sourceforge.net/
>
> "Java developers often come to a point where they wish to deliver
> their application as a single Jar file. The Java Runtime Environment
> supports running a Jar file using the following syntax:
> java -jar /jarname.jar/
>  
> The only requirement of the /jarname.jar/ file is that it contains a
> manifest attribute with the key |Main-Class| a main class to run.
> Suppose the application entry point is the class
> |com.mydomain.mypackage.Main|. Add the following line to the
> |META-INF/MANIFEST.MF| file:
> Main-Class: com.mydomain.mypackage.Main
>  
> So far so good. But, here's where the problems usually start. Any
> non-trivial Java application is going to rely on any number of
> supporting Jar files. For example, using the Apache Commons Logging
> capabilty to do logging an application will need to have the
> |commons-logging.jar| file on its classpath.
>
> Most developers reasonably assume that putting such a Jar file into
> their own Jar file, and adding a |Class-Path| attribute to the
> |META-INF/MANIFEST| will do the trick:
>
> jarname.jar
> | /META-INF
> | | MANIFEST.MF
> | |  Main-Class: com.mydomain.mypackage.Main
> | |  Class-Path: commons-logging.jar
> | /com/mydomain/mypackage
> | | Main.class
> | commons-logging.jar
>  
> Unfortunately this is not the case. The Java classloader does not know
> how to load classes from a Jar inside a Jar. The entries on the
> |Class-Path| must be references to files outside the Jar file,
> defeating the goal of delivering an application in a single Jar file."
> "One-JAR uses a classloader which knows how to load classes and
> resources from Jar files inside a Jar file. To help provide some
> structure to the classloading process, the One-JAR |JarClassLoader|
> looks for a main program inside a |main| directory in the Jar file,
> and looks for supporting Jar files inside a |lib| directory"
>
> Hope this helps someone. Or perhaps I´m making assumptions about the
> way Netrexx works.
>
> FC
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
>
>  

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Tom. (ths@db-123.com)
Reply | Threaded
Open this post in threaded view
|

Re: setting CLASSPATH in java command line

Thomas.Schneider.Wien
In reply to this post by David Requena
Hi David, again,
   maybe I did mis-understand something.

What I have been seeking for is to have only ONE Download necessary (at
least for my bit of SW)

But I think I do now have sufficient information for my case vailable
that I could concentrate
on writing the 'Java like' installation procedure ..

Thanks to all of you for all the hints I got! :-)
Tom.
=================================================================
David Requena schrieb:

> Fernando,
>
> I agree the '-jar' jvm switch is the way to go for your run of the
> mill app with a single entry point, which the NetRexx processor is not
> by any means.
>
> I also fail to see why all the fuzz about the classpath thing. As soon
> as your projects start to grwo bigger you're likely to be including
> all kinds of third party libraries, thus being forced to wrestle with
> classpath in one way or another. Here is where IDE's and tools like
> maven, ant or even the classic make come into play.
>
> While including needed support jar files inside your distribution
> package (zip, tgz, or whatever) is in my view a good idea, I don't see
> the point in merging all the stuff *into a sigle jar* as was initially
> proposed in this thread.
> ---
> Saludos / Kind regards.
> David Requena
>
> El 18/02/2010 22:50, Fernando Cassia escribió:
>>
>>
>> On Thu, Feb 18, 2010 at 5:35 PM, Chip Davis <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>>     Thanks, Tom!  That did the trick too, and is certainly going to
>>     be easier to automate than trying to find the 8-char directory name.
>>
>>
>> At the risk of repeating myself... a properly packaged Java
>> application should be deployed as a single .Jar file and it should
>> run without making any changes to the classpath.
>>
>> See the third reply:
>> http://stackoverflow.com/questions/219585/setting-multiple-jars-in-java-classpath
>>
>> -------------------------------------------------------------------------------------------------------
>>
>> We get around this problem by deploying a *main* jar file |myapp.jar|
>> which contains a *manifest* (|Manifest.mf|) file specifying a
>> classpath with the other required jars, which are then deployed
>> alongside it. In this case, you only need to declare |java -classpath
>> myapp.jar| when running the code.
>>
>> So if you deploy the main |jar| into some directory, and then put the
>> dependent jars into a |lib| folder beneath that, the manifest looks like:
>>
>> |Manifest-Version: 1.0
>>
>> Implementation-Title: myapp
>> Implementation-Version: 1.0.1
>>
>> Class-Path: lib/dep1.jar lib/dep2.jar
>>
>> |
>>
>> NB: this is platform-independent - we can use the same jars to launch
>> on a UNIX server or on a Windows PC.
>>
>> -------------------------------------------------------------------------------------------------------
>>
>> FC
>>
>>
>> _______________________________________________
>> Ibm-netrexx mailing list
>> [hidden email]
>>
>>  
> ------------------------------------------------------------------------
>
> _______________________________________________
> Ibm-netrexx mailing list
> [hidden email]
>
>  

_______________________________________________
Ibm-netrexx mailing list
[hidden email]

Tom. (ths@db-123.com)