Code Comments
Programming Forum and web based access to our favorite programming groups.On Wed, 28 Sep 2005 23:55:32 GMT, "Darren" <Daz@devslashnul.net> wrote or quoted : >Hi i posted a while agoabout signing java applets. With the help of you guy s >my applet now works and is signed. Now i wish to write a java application >with a gui front end that can jar, sign and verify signed jars. are there >jar and signing libraries or will my front end have to shell the command >line commands, keytool, jar and jarsigner? Since the volumes are so low, I think you would find spawning tools to be an easier technique even if you did know how to recreate what they do with standard libraries. If you want to pursue that approach check out: JarEntry JarException JarFile JarInputStream JarOutputStream ZipEntry ZipException ZipFile ZipInputStream ZipOutputStream http://mindprod.com/jgloss/jce.html http://mindprod.com/jgloss/digest.html You also might like to look into ANT for doing this. Here is an ant script to compile, jar, and sign an applet. It also builds a zip and copies files all over the place. You might tackle instead a tool to generate and run an ant script for ant newbies. <?xml version="1.0"?> <!-- Compile and jar wassup using ant --> <!-- Invoke with [ant clean] to erase class files and start over. --> <!-- Invoke with [ant compile] to just compile. --> <!-- Invoke with [ant jar] to compile and create jar files. --> <!-- Invoke with [ant jet] to create jet executables. --> <!-- Invoke with [ant post] to post jar files to website. --> <!-- Invoke with [ant zip] to create source code zip files and post them to the website. --> <!-- For details of ant use, see http://mindprod.com/jgloss/ant.html --> <project name="wassup" basedir="c:/" default="jar"> <!-- D E F I N I T I O N S --> <!-- package.name is com.mindprod.wassup --> <property name="package.name" value="com.mindprod.${ant.project.name}" /> <!-- package.dir is com/mindprod/wassup --> <property name="package.dir" value="com/mindprod/${ant.project.name}" /> <!-- main.class is com.mindprod.wassup.Wassup --> <property name="main.class" value="${package.name}.Wassup" /> <!-- jar.name is wassup.jar --> <property name="jar.name" value="${ant.project.name}.jar" /> <!-- jar.file is com/mindprod/wassup/wassup.jar --> <property name="jar.file" value="${package.dir}/${jar.name}" /> <!-- jar.dir is e:/mindprod/applets --> <property name="jar.dir" value="e:/mindprod/applets" /> <!-- exe.file is com/mindprod/wassup/wassup.exe --> <property name="exe.file" value="${package.dir}/${ant.project.name}.exe" /> <!-- zip.name is wassup22.zip --> <property name="zip.name" value="wassup22.zip" /> <!-- zip.file is com/mindprod/wassup/wassup22.zip --> <property name="zip.file" value="${package.dir}/${zip.name}" /> <!-- zip.dir is e:/mindprod/zips --> <property name="zip.dir" value="e:/mindprod/zips" /> <!-- old.zip.file is e:/mindprod/zips/wassup21.zip --> <property name="old.zip.file" value="${zip.dir}/wassup21.zip" /> <!-- icon.dir is e:/mindprod/icon --> <property name="icon.dir" value="e:/mindprod/icon" /> <!-- pad.dir is e:/mindprod/pads --> <property name="pad.dir" value="e:/mindprod/pads" /> <!-- screenshot.dir is e:/mindprod/screenshots --> <property name="screenshot.dir" value="e:/mindprod/screenshots" /> <!-- precis.dir is e:/mindprod/precis --> <property name="precis.dir" value="e:/mindprod/precis" /> <!-- extensions we distribute --> <property name="distributable.exts" value="**/*.au,**/*.bat,**/*.btm,**/*.c*,**/*.class,**/*.dll,**/*.gif,**/*.h ,**/*.hpp,**/*.htm,**/*.html,**/*.jar,**/*.ico,**/*.java,**/*.jnlp,**/*.jpg, **/*.look,**/*.png,**/*.properties,**/*.ser,**/*.txt,**/*.use,**/*.xml" /> <!-- C L E A N --> <target name="clean"> <echo message="deleting all class, jar and zip files in ${package.dir} tree" /> <delete> <fileset dir="${package.dir}" includes="**/*.class"/> <fileset dir="${package.dir}" includes="**/*.jar"/> <fileset dir="${package.dir}" includes="${zip.name}"/> </delete> </target> <!-- C O M P I L E --> <target name="compile"> <echo message="compiling ${package.dir} tree." /> <javac source="1.2" target="1.1" srcdir="${package.dir}" sourcepath="${basedir}" debug="on"> </javac> </target> <!-- J A V A H --> <target name="javah" depends="compile"> <!-- nothing to do --> </target> <!-- J A R --> <!-- Make genjar known to ant --> <!-- See http://mindprod.com/jgloss/genjar.html for details --> <taskdef resource="genjar.properties" /> <target name="jar" depends="compile"> <genjar jarfile="${jar.file}"> <!-- include main class and all its dependencies --> <class name="${main.class}" /> <!-- define the manifest --> <manifest> <attribute name="Main-Class" value="${main.class}" /> </manifest> </genjar> <!-- S I G N --> <!-- get password from set jarsignerpassword=sesame --> <property environment="env" /> <signjar jar="${jar.file}" alias="mindprodcert2005dsa" storepass="${env.jarsignerpassword}"/> </target> <!-- P R E J E T --> <target name="prejet"> <uptodate property="jet.uptodate" srcfile="${jar.file}" targetfile="${exe.file}" /> </target> <!-- J E T --> <!-- Requires Excelsior Jet native Java compiler --> <!-- See http://mindprod.com/jgloss/jet.html for details --> <target name="jet" depends="prejet" unless="jet.uptodate"> <exec executable="jc.exe" dir="${package.dir}"> <arg value="${jar.name}" /> </exec> <!-- copy exe to c:/sys --> <copy file="${exe.file}" todir="c:/sys" /> </target> <!-- P O S T --> <target name="post" depends="jar"> <!-- copy jar to website --> <copy file="${jar.file}" todir="${jar.dir}" /> </target> <!-- Z I P --> <target name="zip" depends="post"> <!-- copy run html from website to project dir, if it exists --> <available property="has.run" file="${jar.dir}/${ant.project.name}.html" /> <antcall target="copy.run" /> <!-- copy manual html from website to project dir, if it exists --> <available property="has.manual" file="${jar.dir}/${ant.project.name}manual.html" /> <antcall target="copy.manual" /> <!-- copy icon png from website to project dir, if it exists --> <available property="has.icon" file="${icon.dir}/${ant.project.name}.png" /> <antcall target="copy.icon" /> <!-- copy screenshot png from website to project dir, if it exists --> <available property="has.icon" file="${screenshot.dir}/${ant.project.name}screenshot.png" /> <antcall target="copy.screenshot" /> <!-- copy PAD xml from website to project dir, if it exists --> <available property="has.pad.xml" file="${pad.dir}/${ant.project.name}.xml" /> <antcall target="copy.pad.xml" /> <!-- copy PAD htm from website to project dir, if it exists --> <available property="has.pad.htm" file="${pad.dir}/${ant.project.name}.htm" /> <antcall target="copy.pad.htm" /> <zip destfile="${zip.file}" duplicate="preserve" filesonly="true"> <zipfileset dir="${package.dir}" prefix="${package.dir}" includes="${distributable.exts}" /> <zipfileset dir="com/mindprod/common11" prefix="com/mindprod/common11" includes="${distributable.exts}" /> </zip> <!-- copy precis to website --> <copy file="${package.dir}/${ant.project.name}.use" tofile="${precis.dir}/${ant.project.name}.txt" overwrite="true" /> <!-- copy zip to website --> <copy file="${zip.file}" todir="${zip.dir}" overwrite="true" /> <!-- delete old zip distributable from website --> <delete file="${old.zip.file}" failonerror="false" /> </target> <!-- copy run from website to project dir, if there is one. --> <target name="copy.run" if="has.run"> <copy file="${jar.dir}/${ant.project.name}.html" todir="${package.dir}" failonerror="false" overwrite="true" /> </target> <!-- copy manual from website to project dir, if there is one. --> <target name="copy.manual" if="has.manual"> <copy file="${jar.dir}/${ant.project.name}manual.html" todir="${package.dir}" failonerror="false" overwrite="true" /> </target> <!-- copy icon from website to project dir, if there is one. --> <target name="copy.icon" if="has.icon"> <copy file="${icon.dir}/${ant.project.name}.png" todir="${package.dir}" failonerror="false" overwrite="true" /> </target> <!-- copy screenshot from website to project dir, if there is one. --> <target name="copy.screenshot" if="has.screenshot"> <copy file="${screenshot.dir}/${ant.project.name}screenshot.png" todir="${package.dir}" failonerror="false" overwrite="true" /> </target> <!-- copy pad xml from website to project dir, if there is one. --> <target name="copy.pad.xml" if="has.pad.xml"> <copy file="${pad.dir}/${ant.project.name}.xml" todir="${package.dir}" failonerror="false" overwrite="true" /> </target> <!-- copy pad htm from website to project dir, if there is one. --> <target name="copy.pad.htm" if="has.pad.htm"> <copy file="${pad.dir}/${ant.project.name}.htm" todir="${package.dir}" failonerror="false" overwrite="true" /> </target> </project> -- Canadian Mind Products, Roedy Green. http://mindprod.com Again taking new Java programming contracts.
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.