The Source for Java Technology Collaboration

Home » java.net Forums » General Desktop Discussions » General Desktop Issues & Discussion

Thread: Launching a java application under windows

Welcome, Guest Help
Login Login
Guest Settings Guest Settings
This question is answered.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 6 - Last Post: Jun 3, 2007 10:55 AM by: greeneyed Threads: [ Previous | Next ]
aberrant

Posts: 90
Launching a java application under windows
Posted: May 31, 2007 2:53 PM
 
  Click to reply to this thread Reply

Our product uses a batch file to launch our swing app. We are running into a problem though because Windows 2000 has a command line limit of 2047 and our classpath is starting to hit this limit. Is there some other way to pass the classpath to the JVM?

Thanks,

Aberrant

twalljava

Posts: 94
Re: Launching a java application under windows
Posted: May 31, 2007 7:59 PM   in response to: aberrant
Correct
  Click to reply to this thread Reply

Put the classpath into the Class-Path attribute of the manifest of your main jar file. Then your batch file can be as simple as this:

java -jar main.jar

aberrant

Posts: 90
Re: Launching a java application under windows
Posted: Jun 1, 2007 3:31 AM   in response to: twalljava
 
  Click to reply to this thread Reply

I think that will work, but our installer places files in different places, depending on the platform. I think I'm going to encourage the install person to keep them all in the same relative location. Thanks.

jmguillemette

Posts: 7
Re: Launching a java application under windows
Posted: Jun 1, 2007 5:30 AM   in response to: aberrant
Helpful
  Click to reply to this thread Reply

Your manifest entry can include directories too.. but only jars will be loaded when you just specific a directory.

fullung

Posts: 1
Re: Launching a java application under windows
Posted: Jun 1, 2007 6:17 AM   in response to: aberrant
 
  Click to reply to this thread Reply

Or you can use the JarJar Ant task to unpack all your jars and repack them into a single jar that contains your entire application.

Example from JRuby's build.xml:

<target name="jar-complete" depends="generate-method-classes" description="Create the 'complete' JRuby jar. Pass 'mainclass' and 'filename' to adjust.">
<property name="mainclass" value="org.jruby.Main"/>
<property name="filename" value="jruby-complete.jar"/>
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="${lib.dir}/jarjar-0.7.jar"/>
<jarjar destfile="${lib.dir}/${filename}">
<fileset dir="${jruby.classes.dir}">
<exclude name="org/jruby/util/ant/**/*.class"/>
</fileset>
<fileset dir="${basedir}/lib/ruby/1.8">
<include name="**/*.rb"/>
</fileset>
<zipfileset src="${lib.dir}/asm-2.2.3.jar"/>
<zipfileset src="${lib.dir}/asm-commons-2.2.3.jar"/>
<zipfileset src="${lib.dir}/jline-0.9.91.jar"/>
<zipfileset src="${lib.dir}/backport-util-concurrent.jar"/>
<rule pattern="org.objectweb.asm.**" result="jruby.objectweb.asm.@1"/>
<zipfileset dir="${basedir}" prefix="META-INF/jruby.home">
<include name="bin/*"/>
<include name="lib/ruby/gems/1.8/cache/sources*.gem"/>
<include name="lib/ruby/gems/1.8/gems/sources*/**/*"/>
<include name="lib/ruby/gems/1.8/specifications/sources*.gemspec"/>
<include name="lib/ruby/site_ruby/**/*"/>
</zipfileset>
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Main-Class" value="${mainclass}"/>
</manifest>
</jarjar>
</target>

JarJar lives on SourceForge.net: http://sourceforge.net/projects/jarjar

Message was edited by: fullung

Message was edited by: fullung

ivanooi

Posts: 14
Re: Launching a java application under windows
Posted: Jun 1, 2007 7:19 PM   in response to: aberrant
 
  Click to reply to this thread Reply

Forget about batch file. Try this :-

jsmooth.sf.net

it give you .exe file

greeneyed

Posts: 35
Re: Launching a java application under windows
Posted: Jun 3, 2007 10:55 AM   in response to: aberrant
Helpful
  Click to reply to this thread Reply

If/when you are lucky enough to be able to use Java 6, you will be able to use * in directories with .jar files to include them all.
That should help.

OTOH, until that, the Class-Path seems to be the way to go. Just be aware that once you use java -jar whatever.jar, "-cp" and the CLASSPATH environment do nothing and everything has to be specified through the manifest. Just in case ;).

S!




 XML java.net RSS