Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Note that I already have a CLASSPATH env var that points to the location of all of the .jar files, so perhaps it's as easy as a simple M$-style modification to the last line?
#!/usr/bin/env sh
scriptdir=`dirname $0`
classpath="$scriptdir/lib/antlr-2.7.7.jar:$scriptdir/lib/mysql-connector-java-5.1.20-bin.jar:$scriptdir/lib/hibernate-commons-annotations-4.0.1.Final.jar:<a whole bunch of other jar files>:$scriptdir/lib/org.hibernate.common.hibernate-commons-annotations-4.0.1.Final.jar:$scriptdir/lib/gluetop_2.10-0.1.4.jar"
exec java -Dhttp.port=9999 $* -cp "$classpath" play.core.server.NettyServer `dirname $0`
@FireRat, there is nothing at the company's website to link to; that isn't an option.
:: put this in a file called start.bat
set scriptdir=%~dp0set classpath=%scriptdir%lib/antlr-2.7.7.jar;<etc...>%scriptdir%lib/gluetop_2.10-0.1.4.jar
java -Dhttp.port=9999 %* -cp %classpath% play.core.server.NettyServer %~dp0
You might need to put quotes around %scriptdir% in the last line, but if all your paths are without whitespace maybe not. The rules for quoting in batch files are somewhat crazy, you can't just always quote for safety like in unix.
It's also possible it would work from cygwin if you just change the ":" to ";" in the classpath.
Last edited by ntubski; 09-13-2013 at 04:47 PM.
Reason: remove stray quote; had %scriptdir% where %classpath% was wanted
Hmm, if all the jars are in the same dir maybe using wildcard in the classpath as mentioned in that link from YankeePride13 would help:
Quote:
Class path wildcards allow you to include an entire directory of .jar files in the class path without explicitly naming them individually. For more information, including an explanation of class path wildcards, and a detailed description on how to clean up the CLASSPATH environment variable, see the Setting the Class Path technical note.
Code:
set classpath=%scriptdir%lib/*
Oh, also I left a stray quote on that line, not sure if that's relevant.
Even with your suggestion, it's a heckofa long set of .jar files, so I'd easily still be exceeding the 256-char limit of the M$ world. The .jars all reside in the same directory, however.
java -Dhttp.port=9999 %* -cp %scriptdir% play.core.server.NettyServer %~dp0
java -Dhttp.port=9999 %* -cp %scriptdir%lib/*; play.core.server.NettyServer %~dp0
:: oops, my original actually should have been
java -Dhttp.port=9999 %* -cp %classpath% play.core.server.NettyServer %~dp0
But like I said the ; is not needed and could cause problems.
It also occurs to me that setting the variable classpath is enough: there is no need to pass the jars on command line again:
Code:
set scriptdir=%~dp0
set classpath=%scriptdir%lib/antlr-2.7.7.jar;<etc...>%scriptdir%lib/gluetop_2.10-0.1.4.jar
java -Dhttp.port=9999 %* play.core.server.NettyServer %~dp0
Last edited by ntubski; 09-13-2013 at 04:50 PM.
Reason: %scriptdir% -> %classpath%
1) The path for all of the .jars is so long that Windows can't handle it.
The 2 possible solutions 1 possible solution would be:
Specifying the .jars with a wildcard, thereby avoiding passing every single one via command line (this assumes most are in the same directory, not necessarily all but enough to make the list fit under the limit).
Code:
set scriptdir=%~dp0
java -Dhttp.port=9999 -cp %scriptdir%lib/* %* play.core.server.NettyServer %~dp0
Specifying the .jars by setting the classpath variable instead the -cp option, this avoids the command line limit (assumes you don't hit the environment variable length limit, is there one?).
Code:
set scriptdir=%~dp0
set classpath=%scriptdir%lib/antlr-2.7.7.jar;<etc...>%scriptdir%lib/gluetop_2.10-0.1.4.jar
java -Dhttp.port=9999 %* play.core.server.NettyServer %~dp0
Quote:
2) Should it really be %scriptdir%lib...etc. Isn't a slash missing, e.g., %scriptdir%/lib...?
%~dp0 includes a trailing slash (a backslash, in fact).
Last edited by ntubski; 09-14-2013 at 10:14 AM.
Reason: command line limit applies to set commands
The maximum size of a user-defined environment variable is 32,767 characters. There is no technical limitation on the size of the environment block. However, there are practical limits depending on the mechanism used to access the block. For example, a batch file cannot set a variable that is longer than the maximum command line length.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.