Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Tuesday, June 6, 2017

Monday, March 14, 2016

Maven antrun java.io.IOException: "Cannot run program" because "The filename or extension is too long"

There is an issue on where the command that maven antrun fails to run a java because the command line is too long.
In my case the classpath was way too long.

To fix it the classpath needs to be written to a manifest in a jar file and that needs to be used by java to get the classpath.

Here is an example of how to do it:


<manifestclasspath property="manifest.classpath"
                   jarfile="target/classpathSupplier.jar"
                   maxParentLevels="99">
    <classpath refid="maven.compile.classpath" />
</manifestclasspath>
<!-- Create pathing Jar --><jar destfile="target/classpathSupplier.jar">
    <manifest>
        <attribute name="Class-Path" value="${manifest.classpath}"/>
    </manifest>
</jar>
<java classname="org.me.ClassToRun" fork="yes" failonerror="true">
    <arg value="-someArg" />
    <!--<jvmarg value="-Xdebug"/>-->
    <!--<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"/>-->
    <classpath>
        <pathelement location="target/classpathSupplier.jar"/>
    </classpath>
</java>

Thursday, February 18, 2016

Look into jar files using Windows Explorer

I sometimes want to look inside of jar files, and have been copying then to .zip and then using windows explorer to look inside them.  I just found out you can do this in a Admin Console:

assoc .jar=CompressedFolder

After which you can double click on a jar file in explorer and it gives you the choice to run it or open it explorer which then lets you look inside.

Tuesday, September 1, 2015

Java -jar debug with -Xdebug

I had trouble attaching when running a jar via:
java -jar

Seems like all the param after -jar are parameters to it.
So I had to put the -Xdebug _before_ the -jar flag.

Wednesday, August 19, 2015

Java FAQ


Remote Debugging, what to add on the command line to allow it:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005


Tuesday, August 18, 2015

Java executable JAR: What class does it run?

I wanted to unpack a jar file and run it so I could tweak some properties.
I found I had to use jar to unpack it (zip had name collisions).
After unpacking look here to find out what class to run:

META-INF/MANIFEST.MF

Look at the value of:
Main-Class:

It is the class to run.

Just use java to run it:

java -cp PATH_TO_UNPACKED_FILES FULLY_QUALIFIED_PATH_OF_CLASS_TO_RUN

Monday, August 3, 2015