Jsmooth patch with 64 bits skeletons

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1697 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2011-06-07 08:46:33 +00:00
parent b5f500f393
commit 448c2f5f7a
38 changed files with 3415 additions and 2 deletions

View File

@ -0,0 +1,607 @@
<project name="jsmoothgen" default="jar" basedir=".">
<!-- set here the properties specific to your computer -->
<!-- see the README.txt file for additional information -->
<!-- DO NOT SKIP THIS PART! REALLY! IT WON'T WORK OTHERWISE -->
<property name="JDKDIR" value="c:\Program Files\Java\jdk1.5.0_11"/>
<property name="RM" value="CMD /C DEL"/>
<!-- the autodownload skeleton needs the fltk lib to be available -->
<!-- Unfortunately, I couldn't find a way to call fltk-config -->
<!-- directly from ANT or from the makefile. To find the correct -->
<!-- values for your system, run the msys/mingw shell and type -->
<!-- "fltk-config __ldflags" and "fltk-config __cxxflags" -->
<!-- (replace each _ with a - above, due to xml syntax constraints -->
<!-- Then, add the windows path so that the makefile gets it right -->
<!-- Below are the default values when you ./configure, make and -->
<!-- make install fltk under an msys environement -->
<property name="fltk-ldflags" value="-LC:/msys/1.0/local/lib -mwindows -mno-cygwin -lfltk -lole32 -luuid -lcomctl32 -lwsock32"/>
<property name="fltk-cxxflags" value="-IC:/msys/1.0/local/include -IC:/msys/1.0/local/include/FL/images -mwindows -DWIN32 -mno-cygwin"/>
<!-- What's below is optional (needed only if you build a dist) -->
<property name="FOP" value="c:/Programs/fop-0.93\fop.bat"/>
<property name="DOCBOOKBASE" value="c:\programs\docbook-xsl-1.72.0"/>
<!-- set here the properties specific to the release -->
<property name="VERSION" value="0.9.9-7"/>
<!-- You don't need to modify the properties below -->
<property environment="env"/>
<property name="src" value="src"/>
<property name="tmp" value="tmp"/>
<property name="docs" value="docs"/>
<property name="anttask-src" value="ant"/>
<property name="classes" value="classes"/>
<property name="jsmoothjar" value="jsmoothgen.jar"/>
<property name="jsmoothjar-ant" value="jsmoothgen-ant.jar"/>
<property name="ant.jar" value="${env.ANT_HOME}/lib/ant.jar"/>
<property name="distbase" value="dist"/>
<property name="dist" value="${distbase}/jsmooth-${VERSION}"/>
<path id="anttask-compile.class.path">
<pathelement path="${ant.jar}"/>
<pathelement path="${jsmoothjar}/"/>
<pathelement path="lib/JimiProClasses.zip"/>
<pathelement path="lib/jox116.jar"/>
<pathelement path="lib/dtdparser113.jar"/>
</path>
<path id="anttask.class.path">
<pathelement path="${ant.jar}"/>
<pathelement path="${jsmoothjar-ant}/"/>
<pathelement path="lib/JimiProClasses.zip"/>
<pathelement path="lib/jox116.jar"/>
<pathelement path="lib/dtdparser113.jar"/>
</path>
<path id="jsmooth.class.path">
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="skeletons/jnismooth">
<include name="*.jar"/>
</fileset>
</path>
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${classes}"/>
</target>
<target depends="init" name="compile">
<!-- Compile the java code from ${src} into ${classes} -->
<echo>Compiling the application from ${src}</echo>
<javac target="1.4" source="1.4" deprecation="yes" destdir="${classes}" srcdir="${src}" debug="true">
<classpath refid="jsmooth.class.path"/>
</javac>
</target>
<target name="docs" depends="init">
<!-- Compile the java code from ${src} into ${classes} -->
<xslt basedir="${docs}" destdir="${docs}"
in="${docs}/jsmooth-doc.xml"
out="${docs}/jsmooth-doc.html"
style="${DOCBOOKBASE}/html/docbook.xsl" >
<param name="admon.graphics" expression="1"/>
<param name="section.autolabel" expression="1"/>
<param name="section.label.includes.component.label" expression="1"/>
<param name="chunk.section.depth" expression="2"/>
<param name="html.stylesheet" expression="jsmooth.css"/>
</xslt>
<xslt basedir="${docs}" destdir="${docs}"
in="${docs}/jsmooth-doc.xml"
out="${docs}/jsmooth-doc.fo"
style="${DOCBOOKBASE}/fo/docbook.xsl" >
<param name="admon.graphics" expression="1"/>
<param name="section.autolabel" expression="1"/>
<param name="section.label.includes.component.label" expression="1"/>
</xslt>
<exec executable="${FOP}" dir="${docs}">
<arg value="jsmooth-doc.fo"/>
<arg value="jsmooth-doc.pdf"/>
</exec>
</target>
<target depends="compile" name="jar">
<!-- Compile the java code from ${src} into ${classes} -->
<copy todir="classes/icons">
<fileset dir="${src}/icons"/>
</copy>
<copy todir="classes/locale">
<fileset dir="${src}/locale"/>
</copy>
<jar basedir="classes" jarfile="${jsmoothjar}" manifest="src\MANIFEST.txt"/>
</target>
<target depends="compile" name="anttask">
<!-- Compile the java code from ${src} into ${classes} -->
<javac deprecation="yes" destdir="${classes}" srcdir="${anttask-src}" debug="true">
<classpath refid="anttask-compile.class.path"/>
</javac>
<unjar src="lib/jox116.jar" dest="${classes}"/>
<unjar src="lib/dtdparser113.jar" dest="${classes}"/>
<jar basedir="classes" jarfile="${jsmoothjar-ant}" manifest="src\MANIFEST.txt"/>
</target>
<!--
Builds the distribution file for jsmooth.
-->
<target depends="jar" name="test">
<echo>Running test class... ${jsmoothjar}</echo>
<java classname="net.charabia.jsmoothgen.application.gui.beaneditors.BeanPanel" fork="yes" >
<classpath refid="jsmooth.class.path"/>
<classpath>
<pathelement path="${jsmoothjar}"/>
</classpath>
</java>
</target>
<target depends="" name="dist">
<tstamp/>
<buildnumber/>
<property name="RELEASEINFO" value="Build ${DSTAMP}-${build.number}"/>
<echo>Building release ${VERSION} - ${RELEASEINFO}</echo>
<!-- Clean up the directories -->
<antcall target="clean"/>
<!-- Clean up the distribution directory -->
<delete dir="${distbase}"/>
<mkdir dir="${dist}"/>
<mkdir dir="${dist}/docs"/>
<mkdir dir="${dist}/lib"/>
<mkdir dir="${dist}/sample"/>
<mkdir dir="${dist}/skeletons"/>
<!-- Compile the classes and create the jars -->
<!-- The sources are copied in a temp dir, so that -->
<!-- the VERSION and RELEASEINFO data can be replaced -->
<delete dir="${tmp}"/>
<mkdir dir="${tmp}"/>
<copy todir="${tmp}/src">
<fileset dir="src"/>
</copy>
<replace token="@{VERSION}@" dir="${tmp}/src" value="${VERSION}">
<include name="**/*.java"/>
</replace>
<replace token="@{RELEASEINFO}@" dir="${tmp}/src" value="${RELEASEINFO}">
<include name="**/*.java"/>
</replace>
<replace token="@{VERSION}@" dir="${tmp}/src" value="${VERSION}">
<include name="**/*.properties"/>
</replace>
<replace token="@{RELEASEINFO}@" dir="${tmp}/src" value="${RELEASEINFO}">
<include name="**/*.properties"/>
</replace>
<ant antfile="build.xml" dir="skeletons/jnismooth/" target="dist"/>
<antcall target="jar">
<param name="src" value="${tmp}/src"/>
</antcall>
<antcall target="anttask">
<param name="src" value="${tmp}/src"/>
</antcall>
<!-- Copy the jsmooth ant library -->
<copy todir="${dist}/lib" file="jsmoothgen.jar"/>
<copy todir="${dist}/lib" file="jsmoothgen-ant.jar"/>
<copy todir="${dist}/lib" file="lib/jox116.jar"/>
<copy todir="${dist}/lib" file="lib/dtdparser113.jar"/>
<copy todir="${dist}/lib" file="lib/l2fprod-common-all.jar"/>
<copy todir="${dist}/lib" file="lib/riverlayout.jar"/>
<copy todir="${dist}/lib" file="lib/BrowserLauncher2-10.jar"/>
<!-- Now that the ANT task is available, register it -->
<taskdef name="jsmoothgen"
classname="net.charabia.jsmoothgen.ant.JSmoothGen"
classpathref="anttask.class.path"/>
<!-- Builds the documentation -->
<copy todir="${tmp}/docs">
<fileset dir="docs"/>
</copy>
<replace token="@{VERSION}@" dir="${tmp}/docs/" value="${VERSION}">
<include name="**/*.xml"/>
<include name="**/*.txt"/>
<include name="**/*.properties"/>
</replace>
<replace token="@{RELEASEINFO}@" dir="${tmp}/docs/" value="${RELEASEINFO}">
<include name="**/*.xml"/>
<include name="**/*.txt"/>
<include name="**/*.properties"/>
</replace>
<antcall target="docs">
<param name="docs" value="${tmp}/docs"/>
</antcall>
<copy todir="${dist}/docs">
<fileset dir="${tmp}/docs">
<include name="**/*.pdf"/>
</fileset>
<fileset dir="${tmp}/docs">
<include name="**/*.html"/>
</fileset>
<fileset dir="${tmp}/docs">
<include name="**/*.css"/>
</fileset>
</copy>
<copy todir="${dist}/docs/images">
<fileset dir="${tmp}/docs/images"/>
</copy>
<copy todir="${dist}" file="readme.txt"/>
<copy todir="${dist}" file="LICENSE.txt"/>
<copy todir="${dist}" file="LGPL-LICENSE.txt"/>
<copy todir="${dist}" file="GPL-LICENSE.txt"/>
<copy tofile="${dist}/Changelog.txt" file="Changelog"/>
<!-- Compile the wrappers -->
<ant antfile="build.xml" dir="skeletons/jnismooth/" target="dist"/>
<ant antfile="build.xml" dir="skeletons/samplejar/" target="dist"/>
<ant antfile="build.xml" dir="skeletons/consolewrapper/samplejar/" target="dist"/>
<mkdir dir="${dist}/jni"/>
<copy todir="${dist}/jni" file="skeletons/jnismooth/jnismooth.jar"/>
<javadoc packagenames="jsmooth.*"
sourcepath="skeletons/jnismooth/src"
destdir="${dist}/docs/jniapi"
author="true"
version="true"
use="true"
windowtitle="JSmooth JNI API" />
<!-- build all 32bit wrappers -->
<mkdir dir="${dist}/skeletons/windowed-wrapper"/>
<mkdir dir="${dist}/skeletons/console-wrapper"/>
<mkdir dir="${dist}/skeletons/autodownload-wrapper"/>
<mkdir dir="${dist}/skeletons/winservice-wrapper"/>
<antcall target="compileskels">
<param name="skelflags" value="-static-libgcc"/>
</antcall>
<copy todir="${dist}/skeletons/windowed-wrapper" file="skeletons/simplewrap/jwrap.exe"/>
<copy todir="${dist}/skeletons/windowed-wrapper" file="skeletons/simplewrap/description.skel"/>
<copy todir="${dist}/skeletons/console-wrapper" file="skeletons/consolewrapper/consolewrapper.exe"/>
<copy todir="${dist}/skeletons/console-wrapper" file="skeletons/consolewrapper/description.skel"/>
<copy todir="${dist}/skeletons/autodownload-wrapper" file="skeletons/autodownload/autodownload.skel"/>
<copy todir="${dist}/skeletons/autodownload-wrapper" file="skeletons/autodownload/customdownload.skel"/>
<copy todir="${dist}/skeletons/autodownload-wrapper" file="skeletons/autodownload/autodownload.exe"/>
<copy todir="${dist}/skeletons/winservice-wrapper" file="skeletons/winservice/description.skel"/>
<copy todir="${dist}/skeletons/winservice-wrapper" file="skeletons/winservice/winservice.exe"/>
<exec executable="c:\mingw-w32\bin\strip.exe" dir="${dist}/skeletons/console-wrapper">
<arg value="consolewrapper.exe"/>
</exec>
<exec executable="c:\mingw-w32\bin\strip.exe" dir="${dist}/skeletons/windowed-wrapper">
<arg value="jwrap.exe"/>
</exec>
<exec executable="c:\mingw-w32\bin\strip.exe" dir="${dist}/skeletons/autodownload-wrapper">
<arg value="autodownload.exe"/>
</exec>
<exec executable="c:\mingw-w32\bin\strip.exe" dir="${dist}/skeletons/winservice-wrapper">
<arg value="winservice.exe"/>
</exec>
<!-- build all 64bits wrappers -->
<antcall target="clean64"/>
<mkdir dir="${dist}/skeletons/windowed-wrapper64"/>
<mkdir dir="${dist}/skeletons/console-wrapper64"/>
<!-- not available for x64
<mkdir dir="${dist}/skeletons/autodownload-wrapper64"/>
-->
<mkdir dir="${dist}/skeletons/winservice-wrapper64"/>
<antcall target="compileskels64">
<param name="skelflags" value="-static-libgcc"/>
</antcall>
<copy todir="${dist}/skeletons/windowed-wrapper64" file="skeletons/simplewrap/jwrap.exe"/>
<copy todir="${dist}/skeletons/windowed-wrapper64" file="skeletons/simplewrap/description64.skel"/>
<copy todir="${dist}/skeletons/console-wrapper64" file="skeletons/consolewrapper/consolewrapper.exe"/>
<copy todir="${dist}/skeletons/console-wrapper64" file="skeletons/consolewrapper/description64.skel"/>
<!-- not available for x64
<copy todir="${dist}/skeletons/autodownload-wrapper64" file="skeletons/autodownload/autodownload64.skel"/>
<copy todir="${dist}/skeletons/autodownload-wrapper64" file="skeletons/autodownload/customdownload64.skel"/>
<copy todir="${dist}/skeletons/autodownload-wrapper64" file="skeletons/autodownload/autodownload.exe"/>
-->
<copy todir="${dist}/skeletons/winservice-wrapper64" file="skeletons/winservice/description64.skel"/>
<copy todir="${dist}/skeletons/winservice-wrapper64" file="skeletons/winservice/winservice.exe"/>
<exec executable="c:\mingw-w64\bin\strip.exe" dir="${dist}/skeletons/console-wrapper64">
<arg value="consolewrapper.exe"/>
</exec>
<exec executable="c:\mingw-w64\bin\strip.exe" dir="${dist}/skeletons/windowed-wrapper64">
<arg value="jwrap.exe"/>
</exec>
<!-- not available for x64
<exec executable="c:\mingw-w64\bin\strip.exe" dir="${dist}/skeletons/autodownload-wrapper64">
<arg value="autodownload.exe"/>
</exec>
-->
<exec executable="c:\mingw-w64\bin\strip.exe" dir="${dist}/skeletons/winservice-wrapper64">
<arg value="winservice.exe"/>
</exec>
<!-- Builds the jsmooth executable -->
<jsmoothgen project="jsprj/jsmoothgen.jsmooth" skeletonroot="${dist}/skeletons"/>
<jsmoothgen project="jsprj/jsmoothcmd.jsmooth" skeletonroot="${dist}/skeletons"/>
<jsmoothgen project="jsprj/jsmoothcmd64.jsmooth" skeletonroot="${dist}/skeletons"/>
<ant antfile="build.xml" dir="sample" target="dist"/>
<jsmoothgen project="jsprj/prooftest.jsmooth" skeletonroot="${dist}/skeletons"/>
<jsmoothgen project="jsprj/prooftest64.jsmooth" skeletonroot="${dist}/skeletons"/>
<copy todir="${dist}" file="jsmoothgen.exe"/>
<copy todir="${dist}" file="jsmoothcmd.exe"/>
<copy todir="${dist}" file="jsmoothcmd64.exe"/>
<copy todir="${dist}" file="proof-test.exe"/>
<copy todir="${dist}" file="proof-test64.exe"/>
<copy todir="${dist}/sample">
<fileset dir="sample"/>
</copy>
</target>
<target name="compileskel" depends="">
<echo>Making ${skelname} ${target}</echo>
<exec executable="c:\mingw-w32\bin\make.exe" dir="skeletons/${skelname}">
<env key="PATH" value="C:\mingw-w32\bin"/>
<arg value="-f"/>
<arg value="Makefile.win"/>
<arg value="${target}"/>
<arg value='CUSTOMFLAGS=${skelflags}'/>
<arg value='"MINGW=c:/mingw-w32"'/>
<arg value='"TARGET=i686-w64-mingw32"'/>
<arg value='"JDK=${JDKDIR}"'/>
<arg value='"RM=${RM}"'/>
<arg value='"FLTK-LDFLAGS=${fltk-ldflags}"'/>
<arg value='"FLTK-CXXFLAGS=${fltk-cxxflags}"'/>
</exec>
</target>
<target name="compileskel64" depends="">
<echo>Making ${skelname} ${target}</echo>
<exec executable="c:\mingw-w64\bin\make.exe" dir="skeletons/${skelname}">
<env key="PATH" value="C:\mingw-w64\bin"/>
<arg value="-f"/>
<arg value="Makefile.win"/>
<arg value="${target}"/>
<arg value='CUSTOMFLAGS=${skelflags}'/>
<arg value='"MINGW=c:/mingw-w64"'/>
<arg value='"TARGET=x86_64-w64-mingw32"'/>
<arg value='"JDK=${JDKDIR}"'/>
<arg value='"RM=${RM}"'/>
<arg value='"FLTK-LDFLAGS=${fltk-ldflags}"'/>
<arg value='"FLTK-CXXFLAGS=${fltk-cxxflags}"'/>
</exec>
</target>
<target name="compileskels" depends="">
<ant dir="skeletons/simplewrap/samplejar" />
<ant dir="skeletons/consolewrapper/samplejar" />
<antcall target="compileskel">
<param name="skelname" value="util-core"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="all"/>
</antcall>
<antcall target="compileskel">
<param name="skelname" value="util-net"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="all"/>
</antcall>
<antcall target="compileskel">
<param name="skelname" value="commonjava"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="all"/>
</antcall>
<antcall target="compileskel">
<param name="skelname" value="consolewrapper"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="all"/>
</antcall>
<antcall target="compileskel">
<param name="skelname" value="simplewrap"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="all"/>
</antcall>
<antcall target="compileskel">
<param name="skelname" value="autodownload"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="all"/>
</antcall>
<antcall target="compileskel">
<param name="skelname" value="winservice"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="all"/>
</antcall>
</target>
<target name="clean">
<delete dir="${classes}"/>
<delete dir="${distbase}"/>
<delete dir="${tmp}"/>
<delete file="${jsmoothjar}"/>
<delete file="${jsmoothjar-ant}"/>
<ant antfile="build.xml" dir="sample" target="clean"/>
<antcall target="compileskel">
<param name="skelname" value="util-core"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="clean"/>
</antcall>
<antcall target="compileskel">
<param name="skelname" value="util-net"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="clean"/>
</antcall>
<antcall target="compileskel">
<param name="skelname" value="commonjava"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="clean"/>
</antcall>
<antcall target="compileskel">
<param name="skelname" value="consolewrapper"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="clean"/>
</antcall>
<antcall target="compileskel">
<param name="skelname" value="simplewrap"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="clean"/>
</antcall>
<antcall target="compileskel">
<param name="skelname" value="autodownload"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="clean"/>
</antcall>
<antcall target="compileskel">
<param name="skelname" value="winservice"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="clean"/>
</antcall>
<delete file="jsmoothgen.exe"/>
<delete file="jsmoothcmd.exe"/>
<delete file="proof-test.exe"/>
</target>
<target name="compileskels64" depends="">
<ant dir="skeletons/simplewrap/samplejar" />
<ant dir="skeletons/consolewrapper/samplejar" />
<antcall target="compileskel64">
<param name="skelname" value="util-core"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="all"/>
</antcall>
<!-- not available for x64
<antcall target="compileskel64">
<param name="skelname" value="util-net"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="all"/>
</antcall>
-->
<antcall target="compileskel64">
<param name="skelname" value="commonjava"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="all"/>
</antcall>
<antcall target="compileskel64">
<param name="skelname" value="consolewrapper"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="all"/>
</antcall>
<antcall target="compileskel64">
<param name="skelname" value="simplewrap"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="all"/>
</antcall>
<!-- not available for x64
<antcall target="compileskel64">
<param name="skelname" value="autodownload"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="all"/>
</antcall>
-->
<antcall target="compileskel64">
<param name="skelname" value="winservice"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="all"/>
</antcall>
</target>
<target name="clean64">
<antcall target="compileskel64">
<param name="skelname" value="util-core"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="clean"/>
</antcall>
<antcall target="compileskel64">
<param name="skelname" value="util-net"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="clean"/>
</antcall>
<antcall target="compileskel64">
<param name="skelname" value="commonjava"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="clean"/>
</antcall>
<antcall target="compileskel64">
<param name="skelname" value="consolewrapper"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="clean"/>
</antcall>
<antcall target="compileskel64">
<param name="skelname" value="simplewrap"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="clean"/>
</antcall>
<antcall target="compileskel64">
<param name="skelname" value="autodownload"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="clean"/>
</antcall>
<antcall target="compileskel64">
<param name="skelname" value="winservice"/>
<param name="skelflags" value="${skelflags}"/>
<param name="target" value="clean"/>
</antcall>
<delete file="jsmoothgen.exe"/>
<delete file="jsmoothcmd.exe"/>
<delete file="proof-test.exe"/>
</target>
<target name="run" depends="jar">
<java classname="net.charabia.jsmoothgen.application.gui.MainFrame" fork="yes" >
<classpath refid="jsmooth.class.path"/>
<classpath>
<pathelement path="${jsmoothjar}"/>
</classpath>
<arg value="c:/temp/test/testservice.jsmooth"/>
</java>
</target>
<target name="runskeletoneditor" depends="jar">
<java classname="net.charabia.jsmoothgen.skeleton.SkeletonEditor" fork="yes" >
<classpath refid="jsmooth.class.path"/>
<classpath>
<pathelement path="${jsmoothjar}"/>
</classpath>
</java>
</target>
<target name="swt-run" depends="jar">
<java classname="net.charabia.jsmoothgen.application.swtgui.JSmoothApplication"
fork="yes" >
<classpath refid="jsmooth.class.path"/>
<classpath>
<pathelement path="${jsmoothjar}"/>
</classpath>
<jvmarg value="-Djava.library.path=lib/os"/>
</java>
</target>
</project>

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<jsmoothproject>
<JVMSearchPath>registry</JVMSearchPath>
<JVMSearchPath>javahome</JVMSearchPath>
<JVMSearchPath>jrepath</JVMSearchPath>
<JVMSearchPath>jdkpath</JVMSearchPath>
<JVMSearchPath>exepath</JVMSearchPath>
<JVMSearchPath>jview</JVMSearchPath>
<classPath>..\lib\jox116.jar</classPath>
<classPath>..\lib\JimiProClasses.zip</classPath>
<classPath>..\lib\dtdparser113.jar</classPath>
<classPath>..\lib\jsmoothgen.jar</classPath>
<embeddedJar>false</embeddedJar>
<executableName>..\jsmoothcmd.exe</executableName>
<iconLocation>..\src\icons\gnome-application-x-jar-bm.gif</iconLocation>
<initialMemoryHeap>-1</initialMemoryHeap>
<javaProperties>
<name>jsmooth.basedir</name>
<value>${EXECUTABLEPATH} </value>
</javaProperties>
<mainClassName>net.charabia.jsmoothgen.application.cmdline.CommandLine</mainClassName>
<maximumMemoryHeap>-1</maximumMemoryHeap>
<maximumVersion></maximumVersion>
<minimumVersion>1.4</minimumVersion>
<uacRequireAdministrator>0</uacRequireAdministrator>
<skeletonName>Console Wrapper</skeletonName>
<skeletonProperties>
<key>Message</key>
<value>This program needs Java 1.4 or higher to run.
Please download it at http://www.java.com</value>
</skeletonProperties>
<skeletonProperties>
<key>PressKey</key>
<value>0</value>
</skeletonProperties>
<skeletonProperties>
<key>Debug</key>
<value>0</value>
</skeletonProperties>
</jsmoothproject>

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<jsmoothproject>
<JVMSearchPath>registry</JVMSearchPath>
<JVMSearchPath>javahome</JVMSearchPath>
<JVMSearchPath>jrepath</JVMSearchPath>
<JVMSearchPath>jdkpath</JVMSearchPath>
<JVMSearchPath>exepath</JVMSearchPath>
<JVMSearchPath>jview</JVMSearchPath>
<classPath>..\lib\jox116.jar</classPath>
<classPath>..\lib\JimiProClasses.zip</classPath>
<classPath>..\lib\dtdparser113.jar</classPath>
<classPath>..\lib\jsmoothgen.jar</classPath>
<embeddedJar>false</embeddedJar>
<executableName>..\jsmoothcmd64.exe</executableName>
<iconLocation>..\src\icons\gnome-application-x-jar-bm.gif</iconLocation>
<initialMemoryHeap>-1</initialMemoryHeap>
<javaProperties>
<name>jsmooth.basedir</name>
<value>${EXECUTABLEPATH} </value>
</javaProperties>
<mainClassName>net.charabia.jsmoothgen.application.cmdline.CommandLine</mainClassName>
<maximumMemoryHeap>-1</maximumMemoryHeap>
<maximumVersion></maximumVersion>
<minimumVersion>1.4</minimumVersion>
<uacRequireAdministrator>0</uacRequireAdministrator>
<skeletonName>Console Wrapper x64</skeletonName>
<skeletonProperties>
<key>Message</key>
<value>This program needs Java 1.4 or higher to run.
Please download it at http://www.java.com</value>
</skeletonProperties>
<skeletonProperties>
<key>PressKey</key>
<value>0</value>
</skeletonProperties>
<skeletonProperties>
<key>Debug</key>
<value>0</value>
</skeletonProperties>
</jsmoothproject>

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<jsmoothproject>
<JVMSearchPath>registry</JVMSearchPath>
<JVMSearchPath>exepath</JVMSearchPath>
<JVMSearchPath>javahome</JVMSearchPath>
<JVMSearchPath>jrepath</JVMSearchPath>
<JVMSearchPath>jdkpath</JVMSearchPath>
<JVMSearchPath>jview</JVMSearchPath>
<classPath>..\lib\jox116.jar</classPath>
<classPath>..\lib\dtdparser113.jar</classPath>
<classPath>..\lib\jsmoothgen.jar</classPath>
<classPath>..\lib\l2fprod-common-all.jar</classPath>
<classPath>..\jsmoothgen.jar</classPath>
<classPath>..\lib\riverlayout.jar</classPath>
<classPath>..\lib\BrowserLauncher2-10.jar</classPath>
<currentDirectory>${EXECUTABLEPATH}</currentDirectory>
<embeddedJar>false</embeddedJar>
<executableName>..\JSmoothGen.exe</executableName>
<iconLocation>..\src\icons\gnome-application-x-jar-bm.gif</iconLocation>
<initialMemoryHeap>-1</initialMemoryHeap>
<mainClassName>net.charabia.jsmoothgen.application.gui.MainFrame</mainClassName>
<maximumMemoryHeap>-1</maximumMemoryHeap>
<maximumVersion></maximumVersion>
<minimumVersion>1.4</minimumVersion>
<uacRequireAdministrator>0</uacRequireAdministrator>
<skeletonName>Autodownload Wrapper</skeletonName>
<skeletonProperties>
<key>Message</key>
<value>Java 1.4 or above has not been found on your computer. Do you want to download a compatible Java Environment?</value>
</skeletonProperties>
<skeletonProperties>
<key>DownloadURL</key>
<value>http://java.sun.com/update/1.6.0/jinstall-6-windows-i586.cab</value>
</skeletonProperties>
<skeletonProperties>
<key>SingleProcess</key>
<value>1</value>
</skeletonProperties>
<skeletonProperties>
<key>SingleInstance</key>
<value>1</value>
</skeletonProperties>
<skeletonProperties>
<key>JniSmooth</key>
<value>1</value>
</skeletonProperties>
<skeletonProperties>
<key>Debug</key>
<value>0</value>
</skeletonProperties>
</jsmoothproject>

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<jsmoothproject>
<JVMSearchPath>registry</JVMSearchPath>
<JVMSearchPath>javahome</JVMSearchPath>
<JVMSearchPath>jrepath</JVMSearchPath>
<JVMSearchPath>jdkpath</JVMSearchPath>
<JVMSearchPath>exepath</JVMSearchPath>
<JVMSearchPath>jview</JVMSearchPath>
<arguments>simpleargument "multiple tokens" c:\my\test\here</arguments>
<embeddedJar>true</embeddedJar>
<executableName>..\proof-test.exe</executableName>
<iconLocation>..\src\icons\stock_web-support.png</iconLocation>
<initialMemoryHeap>-1</initialMemoryHeap>
<jarLocation>..\sample\sample.jar</jarLocation>
<mainClassName>JSmoothPropertiesDisplayer</mainClassName>
<maximumMemoryHeap>-1</maximumMemoryHeap>
<maximumVersion></maximumVersion>
<minimumVersion>1.1</minimumVersion>
<uacRequireAdministrator>0</uacRequireAdministrator>
<skeletonName>Console Wrapper</skeletonName>
<skeletonProperties>
<key>Message</key>
<value>This program needs Java 1.4 or higher to run.
Please download it at http://www.java.com</value>
</skeletonProperties>
<skeletonProperties>
<key>PressKey</key>
<value>0</value>
</skeletonProperties>
<skeletonProperties>
<key>Debug</key>
<value>1</value>
</skeletonProperties>
</jsmoothproject>

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<jsmoothproject>
<JVMSearchPath>registry</JVMSearchPath>
<JVMSearchPath>javahome</JVMSearchPath>
<JVMSearchPath>jrepath</JVMSearchPath>
<JVMSearchPath>jdkpath</JVMSearchPath>
<JVMSearchPath>exepath</JVMSearchPath>
<JVMSearchPath>jview</JVMSearchPath>
<arguments>simpleargument "multiple tokens" c:\my\test\here</arguments>
<embeddedJar>true</embeddedJar>
<executableName>..\proof-test64.exe</executableName>
<iconLocation>..\src\icons\stock_web-support.png</iconLocation>
<initialMemoryHeap>-1</initialMemoryHeap>
<jarLocation>..\sample\sample.jar</jarLocation>
<mainClassName>JSmoothPropertiesDisplayer</mainClassName>
<maximumMemoryHeap>-1</maximumMemoryHeap>
<maximumVersion></maximumVersion>
<minimumVersion>1.1</minimumVersion>
<uacRequireAdministrator>0</uacRequireAdministrator>
<skeletonName>Console Wrapper x64</skeletonName>
<skeletonProperties>
<key>Message</key>
<value>This program needs Java 1.4 or higher to run.
Please download it at http://www.java.com</value>
</skeletonProperties>
<skeletonProperties>
<key>PressKey</key>
<value>0</value>
</skeletonProperties>
<skeletonProperties>
<key>Debug</key>
<value>1</value>
</skeletonProperties>
</jsmoothproject>

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="dist" name="jsmooth-sample">
<!-- set global properties for this build -->
<property name="src" value="src"/>
<property name="classes" value="classes"/>
<path id="build.class.path">
<pathelement path="../skeletons/jnismooth/jnismooth.jar"/>
</path>
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${classes}"/>
</target>
<target depends="init" name="compile">
<!-- Compile the java code from ${src} into ${classes} -->
<javac deprecation="yes" destdir="${classes}" srcdir="${src}" source="1.4" target="1.4">
<classpath refid="build.class.path"/>
</javac>
</target>
<target depends="compile" name="dist">
<!-- Compile the java code from ${src} into ${classes} -->
<jar basedir="classes" jarfile="sample.jar" manifest="src\MANIFEST.txt"/>
</target>
<target name="run" depends="dist">
<java classname="JSmoothPropertiesDisplayer" fork="yes" >
<classpath refid="build.class.path"/>
<classpath>
<pathelement path="sample.jar"/>
</classpath>
</java>
</target>
<target name="clean">
<delete dir="${classes}"/>
<delete file="sample.jar"/>
</target>
</project>

View File

@ -0,0 +1,46 @@
# Project: util-core
PROJECTNAME=autodownload
##libmscabd_la_SOURCES = mspack/system.c mspack/cabd.c mspack/lzxd.c mspack/mszipd.c mspack/qtmd.c
##libmscabd_la_OBJS = system.o cabd.o lzxd.o mszipd.o qtmd.o
SHELL = /bin/sh
RM = rm -f
CPP = ${MINGW}/bin/${TARGET}-g++.exe
CC = ${MINGW}/bin/${TARGET}-gcc.exe
WINDRES = windres.exe
MINGW =
RES = JWrap_private.res
LINKOBJ = main.o execcab.o execexe.o $(RES)
OBJ = main.o execcab.o execexe.o $(libmscabd_la_OBJS) $(RES)
FLTK-LDFLAGS = $(shell fltk-config --ldflags --use-images)
FLTK-CXXFLAGS = $(shell fltk-config --cxxflags --use-images)
##LINKLIBS = ../commonjava/CommonJava.a ../util-core/util-core.a mspack.a ../util-net/util-net.a
LINKLIBS = ../commonjava/CommonJava.a ../util-net/util-net.a ../util-core/util-core.a
LIBS = -static-libgcc -L. -L"$(MINGW)/lib" -lws2_32 -L"${MINGW}/bin/libgcc_s_sjlj-1.dll" -L"/lib" -L"../commonjava" -mwindows -L"../util-core" -L"../util-net" $(LINKLIBS) $(FLTK-LDFLAGS) -lsetupapi -lwininet
INCS = -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32"
CXXINCS = -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" -I"../commonjava" -I"../util-core" -I"../util-net" $(FLTK-CXXFLAGS)
BIN = autodownload.exe
CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)"
CFLAGS = $(INCS)
.PHONY: all all-before all-after clean clean-custom $(PROJECTNAME)
all: all-before $(BIN) all-after
clean: clean-custom
$(RM) $(OBJ) $(BIN) JWrap_private.res
$(BIN): $(LINKOBJ) $(LINKLIBS)
$(CPP) $(CXXFLAGS) $(LINKOBJ) $(LIBS) -o $(BIN)
#mspack.a: $(libmscabd_la_SOURCES)
# $(CC) -c -Imspack $(libmscabd_la_SOURCES)
# ar r mspack.a $(libmscabd_la_OBJS)
# ranlib mspack.a
JWrap_private.res: JWrap_private.rc mainres.rc
$(WINDRES) -i JWrap_private.rc -J rc -o JWrap_private.res -O coff
main.o: main.cpp
$(CPP) -c main.cpp $(CXXFLAGS)

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<jsmoothskeleton>
<debug>false</debug>
<description>SKEL_AUTODOWNLOAD_PROPERTY_DESCRIPTION</description>
<executableName>autodownload.exe</executableName>
<resourceCategory>JAVA</resourceCategory>
<resourceJarId>102</resourceJarId>
<resourcePropsId>103</resourcePropsId>
<shortName>Autodownload Wrapper x64</shortName>
<skeletonProperties>
<description>SKEL_AUTODOWNLOAD_PROPERTY_MESSAGE_DESCRIPTION</description>
<idName>Message</idName>
<label>SKEL_AUTODOWNLOAD_PROPERTY_MESSAGE_LABEL</label>
<type>textarea</type>
<value>Java has not been found on your computer. Do you want to download it?</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_AUTODOWNLOAD_PROPERTY_DLURL_DESCRIPTION</description>
<idName>DownloadURL</idName>
<label>SKEL_AUTODOWNLOAD_PROPERTY_DLURL_LABEL</label>
<type>autodownloadurl</type>
<value>http://java.sun.com/update/1.5.0/jinstall-1_5_0_11-windows-i586.cab</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_GENERIC_PROPERTY_SINGLEPROCESS_DESCRIPTION</description>
<idName>SingleProcess</idName>
<label>SKEL_GENERIC_PROPERTY_SINGLEPROCESS_LABEL</label>
<type>boolean</type>
<value>0</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_GENERIC_SINGLEINSTANCE_DESCRIPTION</description>
<idName>SingleInstance</idName>
<label>SKEL_GENERIC_SINGLEINSTANCE</label>
<type>boolean</type>
<value>0</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_GENERIC_JNISMOOTH_DESCRIPTION</description>
<idName>JniSmooth</idName>
<label>SKEL_GENERIC_JNISMOOTH</label>
<type>boolean</type>
<value>0</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_GENERIC_PROPERTY_DEBUG_DESCRIPTION</description>
<idName>Debug</idName>
<label>SKEL_GENERIC_PROPERTY_DEBUG_LABEL</label>
<type>boolean</type>
<value>0</value>
</skeletonProperties>
</jsmoothskeleton>

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<jsmoothskeleton>
<debug>false</debug>
<description>SKEL_CUSTOMDOWNLOAD_DESCRIPTION</description>
<executableName>autodownload.exe</executableName>
<resourceCategory>JAVA</resourceCategory>
<resourceJarId>102</resourceJarId>
<resourcePropsId>103</resourcePropsId>
<shortName>Custom Web Download Wrapper x64</shortName>
<skeletonProperties>
<description>SKEL_CUSTOMDOWNLOAD_PROPERTY_MESSAGE_DESCRIPTION</description>
<idName>Message</idName>
<label>SKEL_CUSTOMDOWNLOAD_PROPERTY_MESSAGE_LABEL</label>
<type>textarea</type>
<value>Java has not been found on your computer. Do you want to download it?</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_CUSTOMDOWNLOAD_PROPERTY_URL_DESCRIPTION</description>
<idName>DownloadURL</idName>
<label>SKEL_CUSTOMDOWNLOAD_PROPERTY_URL_LABEL</label>
<type>string</type>
<value>http://</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_GENERIC_PROPERTY_SINGLEPROCESS_DESCRIPTION</description>
<idName>SingleProcess</idName>
<label>SKEL_GENERIC_PROPERTY_SINGLEPROCESS_LABEL</label>
<type>boolean</type>
<value>0</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_GENERIC_SINGLEINSTANCE_DESCRIPTION</description>
<idName>SingleInstance</idName>
<label>SKEL_GENERIC_SINGLEINSTANCE</label>
<type>boolean</type>
<value>0</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_GENERIC_JNISMOOTH_DESCRIPTION</description>
<idName>JniSmooth</idName>
<label>SKEL_GENERIC_JNISMOOTH</label>
<type>boolean</type>
<value>0</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_GENERIC_PROPERTY_DEBUG_DESCRIPTION</description>
<idName>Debug</idName>
<label>SKEL_GENERIC_PROPERTY_DEBUG_LABEL</label>
<type>boolean</type>
<value>0</value>
</skeletonProperties>
</jsmoothskeleton>

View File

@ -0,0 +1,9 @@
#include "resource.h"
JARID JAVA "../samplejar/sample.jar"
PROPID JAVA "../samplejar/sample.props"
JNISMOOTHID JAVA "../jnismooth/jnismooth.jar"
A2 ICON MOVEABLE PURE LOADONCALL DISCARDABLE "JWrap.ico"
1 MANIFEST "../samplejar/sample.manifest"

View File

@ -0,0 +1,74 @@
/*
JSmooth: a VM wrapper toolkit for Windows
Copyright (C) 2003-2007 Rodrigo Reyes <reyes@charabia.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "JVMBase.h"
JVMBase::JVMBase()
{
m_maxHeap = -1;
m_initialHeap = -1;
m_vmParameter = "";
}
void JVMBase::addPathElement(const std::string& element)
{
m_pathElements.push_back(element);
}
void JVMBase::addProperty(const JavaProperty& prop)
{
m_properties.push_back(prop);
}
void JVMBase::setMaxHeap(long size)
{
m_maxHeap = size;
}
void JVMBase::setInitialHeap(long size)
{
m_initialHeap = size;
}
void JVMBase::addArgument(const std::string& arg)
{
// m_arguments.push_back(StringUtils::requoteForCommandLine(arg));
m_arguments.push_back(arg);
}
void JVMBase::setArguments(const std::string& args)
{
m_arguments.clear();
DEBUG("arguments:<" + args + ">");
// std::string ua = StringUtils::unescape(args);
// DEBUG("arguments unescaped:<" + ua + ">");
vector<string> splitted = StringUtils::split(args, " \t\n\r", "\"\'", false);
for (int i=0; i<splitted.size(); i++)
{
DEBUG("SPLITTED-ARG[" + StringUtils::toString(i)+"]="+ splitted[i]);
this->addArgument(splitted[i]);
}
}
void JVMBase::setVmParameter(std::string parameter)
{
m_vmParameter = parameter;
}

View File

@ -0,0 +1,61 @@
/*
JSmooth: a VM wrapper toolkit for Windows
Copyright (C) 2003-2007 Rodrigo Reyes <reyes@charabia.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __SUNJVMBASE_H_
#define __SUNJVMBASE_H_
#include <string>
#include "jni.h"
#include "Version.h"
#include "StringUtils.h"
#include "FileUtils.h"
#include "ResourceManager.h"
#include "JavaProperty.h"
/**
* @author Rodrigo Reyes <reyes@charabia.net>
*/
class JVMBase
{
protected:
std::vector<std::string> m_pathElements;
std::vector<JavaProperty> m_properties;
int m_maxHeap;
int m_initialHeap;
std::vector<std::string> m_arguments;
std::string m_vmParameter;
public:
JVMBase();
void addPathElement(const std::string& element);
void addProperty(const JavaProperty& prop);
void setMaxHeap(long size);
void setInitialHeap(long size);
void addArgument(const std::string& arg);
void setArguments(const std::string& args);
void setVmParameter(std::string parameter);
};
#endif

View File

@ -0,0 +1,115 @@
/*
JSmooth: a VM wrapper toolkit for Windows
Copyright (C) 2003-2007 Rodrigo Reyes <reyes@charabia.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "JVMRegistryLookup.h"
struct jvmsorter_dec : public binary_function<const SunJVMLauncher&, const SunJVMLauncher&, bool>
{
bool operator()(const SunJVMLauncher& s1, const SunJVMLauncher& s2)
{
return s2 < s1;
}
};
vector<SunJVMLauncher> JVMRegistryLookup::lookupJVM()
{
vector<SunJVMLauncher> res = JVMRegistryLookup::lookup(HKEY_LOCAL_MACHINE, "SOFTWARE\\JavaSoft\\Java Runtime Environment");
vector<SunJVMLauncher> res2 = JVMRegistryLookup::lookup(HKEY_LOCAL_MACHINE, "SOFTWARE\\JavaSoft\\Java Development Kit");
for (vector<SunJVMLauncher>::iterator i = res2.begin(); i != res2.end(); i++)
{
res.insert(res.end(), *i);
}
sort(res.begin(), res.end(), jvmsorter_dec() );
return res;
}
vector<SunJVMLauncher> JVMRegistryLookup::lookup(HKEY key, const string& path)
{
vector<SunJVMLauncher> result;
HKEY hKey;
LONG error = ERROR_SUCCESS;
LONG val = RegOpenKeyEx(key, path.c_str(), 0, KEY_READ, &hKey);
unsigned long buffersize = 1024;
char buffer[1024];
for (int i=0; RegEnumKey(hKey, i, buffer, buffersize) == ERROR_SUCCESS; i++)
{
int v = i;
HKEY version;
int foundver = RegOpenKeyEx(hKey, buffer, 0, KEY_READ, &version);
if (foundver == ERROR_SUCCESS)
{
std::string versionname(buffer);
HKEY runtimelib;
unsigned long datatype;
std::string runtimelibstr = "";
std::string javahomestr = "";
unsigned char *b = (unsigned char*)buffer;
buffersize = 1024;
int foundlib = RegQueryValueEx(version, TEXT("RuntimeLib"),
NULL,
&datatype,
b,
&buffersize);
if (foundlib == ERROR_SUCCESS)
{
runtimelibstr = buffer;
}
b = (unsigned char*)buffer;
buffersize = 1024;
int foundhome = RegQueryValueEx(version, TEXT("JavaHome"),
NULL,
&datatype,
b,
&buffersize);
if (foundhome == ERROR_SUCCESS)
{
javahomestr = buffer;
}
if ((runtimelibstr.length()>0) || (javahomestr.length()>0))
{
SunJVMLauncher vm;
vm.RuntimeLibPath = runtimelibstr;
vm.JavaHome = javahomestr;
vm.VmVersion = Version(versionname);
result.push_back(vm);
char buffer[244];
sprintf(buffer, "V(%d)(%d)(%d)", vm.VmVersion.getMajor(), vm.VmVersion.getMinor(), vm.VmVersion.getSubMinor());
DEBUG(std::string("JVM Lookup: found VM (") + buffer + ") in registry.");
}
}
}
return result;
}

View File

@ -0,0 +1,52 @@
/*
JSmooth: a VM wrapper toolkit for Windows
Copyright (C) 2003-2007 Rodrigo Reyes <reyes@charabia.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _JVMREGISTRYLOOKUP_H_
#define _JVMREGISTRYLOOKUP_H_
#include <vector>
#include <algorithm>
#include "SunJVMLauncher.h"
#include "JVMRegistryLookup.h"
/** Utility class that scans the windows registry for installed JRE.
*
* @author Rodrigo Reyes <reyes@charabia.net>
*/
class JVMRegistryLookup
{
public:
/**
* Scans the Windows Registry for the Java Runtime Environments. If
* no JRE is found, an empty vector is returned.
*
* @return a vector containing the JRE found.
*/
static vector<SunJVMLauncher> lookupJVM();
private:
static vector<SunJVMLauncher> lookup(HKEY key, const string& path);
};
#endif

View File

@ -0,0 +1,232 @@
/*
JSmooth: a VM wrapper toolkit for Windows
Copyright (C) 2003-2007 Rodrigo Reyes <reyes@charabia.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "JavaMachineManager.h"
JavaMachineManager::JavaMachineManager(ResourceManager& resman): m_resman(resman)
{
DEBUG("Now searching the JVM installed on the system...");
m_registryVms = JVMRegistryLookup::lookupJVM();
m_javahomeVm = JVMEnvVarLookup::lookupJVM("JAVA_HOME");
m_jrepathVm = JVMEnvVarLookup::lookupJVM("JRE_HOME");
m_jdkpathVm = JVMEnvVarLookup::lookupJVM("JDK_HOME");
m_exitCode = 0;
m_useConsole = true;
m_acceptExe = true;
m_acceptDLL = true;
m_preferDLL = false;
if (resman.getProperty("bundledvm").length() > 0)
{
string bjvm = resman.getProperty("bundledvm");
DEBUG("Found a vm bundled with the application: (" + bjvm + ")");
m_localVMenabled = true;
std::string home = FileUtils::concFile(resman.getCurrentDirectory(), bjvm);
m_localVM.JavaHome = home;
} else
{
m_localVMenabled = false;
}
DEBUG("Current directory is " + resman.getCurrentDirectory());
}
bool JavaMachineManager::run()
{
string vmorder = m_resman.getProperty(ResourceManager::KEY_JVMSEARCH);
if (m_localVMenabled)
{
if (internalRun(m_localVM, "bundled"))
{
return true;
}
// DEBUG("Trying to use bundled VM " + m_localVM.JavaHome);
// if (m_localVM.runProc(m_resman, m_useConsole, "bundled"))
// {
// m_exitCode = m_localVM.getExitCode();
// return true;
// }
// if (m_localVM.run(m_resman, "bundled"))
// return true;
}
if (vmorder == "")
{
vmorder = "registry;jdkpath;jrepath;javahome;jview;exepath";
}
DEBUG("JSmooth will now try to use the VM in the following order: " + vmorder);
vector<string> jvmorder = StringUtils::split(vmorder, ";,", "");
Version max(m_resman.getProperty(ResourceManager:: KEY_MAXVERSION));
Version min(m_resman.getProperty(ResourceManager:: KEY_MINVERSION));
for (vector<string>::const_iterator i = jvmorder.begin(); i != jvmorder.end(); i++)
{
DEBUG("------------------------------");
if (*i == "registry")
{
DEBUG("Trying to use a JVM defined in the registry (" + StringUtils::toString(m_registryVms.size()) + " available)");
string vms = "VM will be tried in the following order: ";
for (int i=0; i<m_registryVms.size(); i++)
{
vms += m_registryVms[i].VmVersion.toString();
vms += ";";
}
DEBUG(vms);
for (int i=0; i<m_registryVms.size(); i++)
{
DEBUG("- Trying registry: " + m_registryVms[i].toString());
if (internalRun(m_registryVms[i], "registry") == true)
return true;
DEBUG("Couldn't use this VM, now trying something else");
}
}
else if ((*i == "jview") && m_acceptExe)
{
DEBUG("- Trying to launch the application with JVIEW");
if (m_jviewVm.runProc(m_resman, ! m_useConsole))
{
return true;
}
}
else if ((*i == "javahome") && (m_javahomeVm.size()>0))
{
DEBUG("- Trying to use JAVAHOME");
if (internalRun(m_javahomeVm[0], "jrehome"))
return true;
}
else if ((*i == "jrepath") && (m_jrepathVm.size()>0))
{
DEBUG("- Trying to use JRE_HOME");
if (internalRun(m_jrepathVm[0], "jrehome"))
return true;
}
else if (*i == "exepath")
{
DEBUG("- Trying to use PATH");
SunJVMLauncher launcher;
if (launcher.runProc(m_resman, m_useConsole, "path"))
{
m_exitCode = m_localVM.getExitCode();
return true;
}
}
}
DEBUG("Couldn't run any suitable JVM!");
return false;
}
bool JavaMachineManager::internalRun(SunJVMLauncher& launcher, const string& org)
{
if (m_acceptDLL && m_preferDLL)
{
if (launcher.run(m_resman, org))
return true;
}
if (m_acceptExe)
{
if (launcher.runProc(m_resman, m_useConsole, org))
{
m_exitCode = launcher.getExitCode();
return true;
}
}
if (m_acceptDLL && !m_preferDLL)
{
if (launcher.run(m_resman, org))
return true;
}
return false;
}
SunJVMLauncher* JavaMachineManager::runDLLFromRegistry(bool justInstanciate)
{
string vms = "DLL VM will be tried in the following order: ";
for (int i=0; i<m_registryVms.size(); i++)
{
vms += m_registryVms[i].VmVersion.toString();
vms += ";";
}
DEBUG(vms);
for (int i=0; i<m_registryVms.size(); i++)
{
DEBUG("- Trying registry: " + m_registryVms[i].toString());
bool res = m_registryVms[i].run(m_resman, "registry", justInstanciate);
if (res)
return &m_registryVms[i];
}
if (m_localVMenabled) {
if (m_localVM.run(m_resman, "bundled", justInstanciate)) {
return &m_localVM;
} else {
DEBUG("Bundled VM launch failed");
}
}
return NULL;
}
void JavaMachineManager::setUseConsole(bool useConsole)
{
m_useConsole = useConsole;
}
void JavaMachineManager::setAcceptExe(bool acceptExe)
{
m_acceptExe = acceptExe;
}
void JavaMachineManager::setAcceptDLL(bool acceptDLL)
{
m_acceptDLL = acceptDLL;;
}
void JavaMachineManager::setPreferDLL(bool prefDLL)
{
m_preferDLL = prefDLL;
}
int JavaMachineManager::getExitCode()
{
return m_exitCode;
}

View File

@ -0,0 +1,60 @@
# Project: CommonJava
# Makefile created by Dev-C++ 4.9.8.0
RM = rm -f
CPP = ${MINGW}/bin/${TARGET}-g++.exe
CC = ${MINGW}/bin/${TARGET}-gcc.exe
WINDRES = windres.exe
MINGW =
RES =
OBJ = JniSmooth.o JVMBase.o SunJVMExe.o JArgs.o JClassProxy.o SunJVMDLL.o JavaMachineManager.o JVMEnvVarLookup.o JVMRegistryLookup.o MSJViewLauncher.o Properties.o ResourceManager.o SunJVMLauncher.o Version.o global.o JavaProperty.o JMethodCaller.o $(RES)
LINKOBJ = JniSmooth.o JVMBase.o SunJVMExe.o JArgs.o JClassProxy.o SunJVMDLL.o JavaMachineManager.o JVMEnvVarLookup.o JVMRegistryLookup.o MSJViewLauncher.o Properties.o ResourceManager.o SunJVMLauncher.o Version.o global.o JavaProperty.o JMethodCaller.o $(RES)
LIBS = -static-libgcc -L"$(MINGW)/lib"
INCS = -I"../util-core" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32"
CXXINCS = -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" -I"../commonjava" -I"../util-core" -I"../util-net" $(FLTK-CXXFLAGS)
BIN = CommonJava.a
CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)"
CFLAGS = $(INCS)
.PHONY: all all-before all-after clean clean-custom
all: all-before CommonJava.a all-after
clean: clean-custom
$(RM) $(OBJ) $(BIN)
$(BIN): $(LINKOBJ) test.cpp
ar r $(BIN) $(LINKOBJ)
ranlib $(BIN)
$(CPP) $(CXXFLAGS) test.cpp $(BIN) ../util-core/util-core.a -o test.exe
JavaMachineManager.o: JavaMachineManager.cpp
$(CPP) -c JavaMachineManager.cpp -o JavaMachineManager.o $(CXXFLAGS)
JVMEnvVarLookup.o: JVMEnvVarLookup.cpp
$(CPP) -c JVMEnvVarLookup.cpp -o JVMEnvVarLookup.o $(CXXFLAGS)
JVMRegistryLookup.o: JVMRegistryLookup.cpp
$(CPP) -c JVMRegistryLookup.cpp -o JVMRegistryLookup.o $(CXXFLAGS)
MSJViewLauncher.o: MSJViewLauncher.cpp
$(CPP) -c MSJViewLauncher.cpp -o MSJViewLauncher.o $(CXXFLAGS)
Properties.o: Properties.cpp
$(CPP) -c Properties.cpp -o Properties.o $(CXXFLAGS)
ResourceManager.o: ResourceManager.cpp
$(CPP) -c ResourceManager.cpp -o ResourceManager.o $(CXXFLAGS)
SunJVMLauncher.o: SunJVMLauncher.cpp
$(CPP) -c SunJVMLauncher.cpp -o SunJVMLauncher.o $(CXXFLAGS)
Version.o: Version.cpp
$(CPP) -c Version.cpp -o Version.o $(CXXFLAGS)
global.o: global.cpp
$(CPP) -c global.cpp -o global.o $(CXXFLAGS)
JavaProperty.o: JavaProperty.cpp
$(CPP) -c JavaProperty.cpp -o JavaProperty.o $(CXXFLAGS)

View File

@ -0,0 +1,376 @@
/*
JSmooth: a VM wrapper toolkit for Windows
Copyright (C) 2003-2007 Rodrigo Reyes <reyes@charabia.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "ResourceManager.h"
char * const ResourceManager::KEY_MAINCLASSNAME = "mainclassname";
char * const ResourceManager::KEY_ARGUMENTS = "arguments";
char * const ResourceManager::KEY_CLASSPATH = "classpath";
char * const ResourceManager::KEY_JVMSEARCH = "jvmsearch";
char * const ResourceManager::KEY_MINVERSION = "minversion";
char * const ResourceManager::KEY_MAXVERSION = "maxversion";
char * const ResourceManager::KEY_NOJVMMESSAGE = "nojvmmessage";
char * const ResourceManager::KEY_NOJVMURL = "nojvmurl";
char * const ResourceManager::KEY_BUNDLEDVM = "bundledvm";
char * const ResourceManager::KEY_CURRENTDIR = "currentdir";
char * const ResourceManager::KEY_EMBEDJAR = "embedjar";
ResourceManager::ResourceManager(std::string category, int propsId, int jarId, int jniId)
{
m_resourceCategory = category;
m_resourcePropsId = propsId;
m_resourceJarId = jarId;
//
// Load the Properties
//
DEBUG("Initialize properties...");
std::string propsidstr = this->idToResourceName(propsId);
HRSRC resprop = FindResource(NULL, propsidstr.c_str(), category.c_str());
if (resprop != NULL)
{
int mainsize = 0;
mainsize = SizeofResource(NULL, resprop);
// char mainbuf[mainsize+1];
HGLOBAL main = LoadResource(NULL, resprop);
m_props.setData((const char*)main, mainsize);
}
else
{
m_lastError = "Can't find resource 'main name'";
return;
}
//
// Split the arguments
//
m_arguments = StringUtils::split(getProperty(KEY_ARGUMENTS, ""), " \t\n\r", "\"\'");
//
// loads the jar information
//
std::string jaridstr = this->idToResourceName(jarId);
HRSRC resjar = FindResource(NULL, jaridstr.c_str(), category.c_str());
if (resjar != NULL)
{
m_jarSize = SizeofResource(NULL, resjar);
m_jarHandler = LoadResource(NULL, resjar);
}
else
{
m_lastError = "Can't find JAR resource!";
return;
}
m_jnismoothSize = this->getResourceSize(jniId);
m_jnismoothHandler = this->getResource(jniId);
//
// Extract the java properties from the Property
//
std::string jpropcountstr = m_props.get("javapropertiescount");
string exepath = FileUtils::getExecutablePath();
string exename = FileUtils::getExecutableFileName();
string computername = FileUtils::getComputerName();
int jpropcount = StringUtils::parseInt(jpropcountstr);
DEBUG("Number of Java Parameters: "+jpropcountstr);
for (int i=0; i<jpropcount; i++)
{
string namekey = string("javaproperty_name_") + StringUtils::toString(i);
string valuekey = string("javaproperty_value_") + StringUtils::toString(i);
string name = m_props.get(namekey);
string value = m_props.get(valuekey);
DEBUG("Setting up java properties SOURCE: " + name + "=" + value + " : property if exist: " +getProperty(name,""));
value = StringUtils::replaceEnvironmentVariable(value);
value = StringUtils::replace(value, "${EXECUTABLEPATH}", exepath);
value = StringUtils::replace(value, "${EXECUTABLENAME}", exename);
value = StringUtils::replace(value, "${COMPUTERNAME}", computername);
JavaProperty jprop(name, value);
m_javaProperties.push_back(jprop);
DEBUG("Setting up java properties DESTINATION: " + name + "=" + value);
}
std::string curdirmodifier = m_props.get(ResourceManager::KEY_CURRENTDIR);
if (curdirmodifier.length()>0)
{
int pos = string::npos;
if ( (pos=curdirmodifier.find("${EXECUTABLEPATH}")) != string::npos)
{
m_currentDirectory = FileUtils::concFile(exepath, curdirmodifier.substr(pos + string("${EXECUTABLEPATH}").size()));
// m_currentDirectory = StringUtils::replace(curdirmodifier, "${EXECUTABLEPATH}", exepath);
}
else
{
DEBUG(string("Currentdirectory =") + curdirmodifier);
m_currentDirectory = curdirmodifier;
// m_currentDirectory = FileUtils::concFile(FileUtils::getExecutablePath(), curdirmodifier);
m_currentDirectory = StringUtils::replaceEnvironmentVariable(m_currentDirectory);
}
}
else
{
m_currentDirectory = "";
}
// printf("CURDIR SET TO: [%s]\n", m_currentDirectory.c_str());
}
ResourceManager::~ResourceManager()
{
for (std::vector<std::string>::iterator i=m_deleteOnFinalize.begin(); i != m_deleteOnFinalize.end(); i++)
{
int res = DeleteFile(i->c_str());
}
}
void ResourceManager::setProperty(const std::string& key, const std::string& value)
{
m_props.set(key, value);
}
void ResourceManager::saveTemp(std::string tempname, HGLOBAL data, int size)
{
if ((data == 0) || (size == 0))
return;
HANDLE temp = CreateFile(tempname.c_str(),
GENERIC_WRITE,
FILE_SHARE_WRITE,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (temp != NULL)
{
DWORD reallyWritten;
WriteFile(temp, data, size, &reallyWritten, NULL);
// TODO: check the reallyWritten value for errors
CloseHandle(temp);
string s = tempname;
// m_deleteOnFinalize.push_back(s);
FileUtils::deleteOnReboot(s);
}
}
std::string ResourceManager::getMainName() const
{
return getProperty(string("mainclassname"));
}
std::string ResourceManager::getProperty(const std::string& key) const
{
return m_props.get(key);
}
std::string ResourceManager::getProperty(const std::string& key, const std::string& def) const
{
if (m_props.contains(key))
return m_props.get(key);
else
return def;
}
bool ResourceManager::getBooleanProperty(const std::string& key) const
{
std::string prop = getProperty(key, "0");
if (StringUtils::parseInt(prop)==1)
return true;
if (StringUtils::toLowerCase(prop) == "true")
return true;
return false;
}
std::string ResourceManager::saveJarInTempFile()
{
if (useEmbeddedJar() == false)
return "";
std::string tempfilename = FileUtils::createTempFileName(".jar");
DEBUG("Created temporary filename to hold the jar (" + tempfilename + ")");
saveTemp(tempfilename, m_jarHandler, m_jarSize);
return tempfilename;
}
const vector<JavaProperty>& ResourceManager::getJavaProperties()
{
return m_javaProperties;
}
std::vector<std::string> ResourceManager::getNormalizedClassPathVector() const
{
std::string basepath = FileUtils::getExecutablePath();
std::string curdirmodifier = getCurrentDirectory(); //getProperty(string(ResourceManager::KEY_CURRENTDIR));
if (FileUtils::isAbsolute(curdirmodifier)){
basepath = curdirmodifier;
DEBUG("DEBUG: (absolut) Basepath is : " + basepath);
} else {
basepath = FileUtils::concFile(basepath, curdirmodifier);
DEBUG("DEBUG: (not absolut) Basepath is : " + basepath);
}
std::string cp = getProperty(string(ResourceManager::KEY_CLASSPATH));
vector<string>cps = StringUtils::split(cp, ";", "", false);
for (int i=0; i<cps.size(); i++)
{
string lib = cps[i];
DEBUG("ClassPath element is " + basepath + " + " +cps[i]);
cps[i] = FileUtils::concFile(basepath, cps[i]);
DEBUG("ClassPath element " + StringUtils::toString(i)+ "=" + cps[i]);
}
return cps;
}
std::string ResourceManager::getNormalizedClassPath() const
{
vector<string> cps = getNormalizedClassPathVector();
return StringUtils::join(cps, ";");
}
std::string ResourceManager::getCurrentDirectory() const
{
return m_currentDirectory;
}
bool ResourceManager::useEmbeddedJar() const
{
std::string value = m_props.get(ResourceManager::KEY_EMBEDJAR);
if (value == "true")
return true;
return false;
}
void ResourceManager::printDebug() const
{
DEBUG("ResourceManager resource configuration:");
DEBUG(" - Resource category: " + m_resourceCategory);
DEBUG(" - Current directory: " + m_currentDirectory);
map<string, string> props = m_props.getDataCopy();
DEBUG(" - Property count: " + StringUtils::toString(props.size()));
for (map<string, string>::iterator i = props.begin(); i != props.end(); i++)
{
DEBUG(" - Property: " + i->first + "=<" + i->second+">");
}
}
void ResourceManager::setUserArguments(std::vector<std::string> arguments)
{
m_arguments.clear();
for (std::vector<std::string>::iterator i=arguments.begin(); i != arguments.end(); i++)
{
addUserArgument(*i);
}
}
void ResourceManager::addUserArgument(std::string argument)
{
bool keyFound = false;
if (argument.size()>3)
{
int pos = argument.find("=");
if (pos != std::string::npos)
{
string key = argument.substr(2, pos-2);
string value = argument.substr(pos+1);
string argumentType = argument.substr(0,2);
if (argumentType == "-J")
{
DEBUG("FOUND USER ARGUMENT for JSMOOTH: [" + key + "]=[" + value + "]");
keyFound = true;
setProperty(key, value);
}
if (argumentType == "-D")
{
DEBUG("FOUND USER ARGUMENT for JAVA: [" + key + "]=[" + value + "]");
JavaProperty jprop(key, value);
keyFound = true;
m_javaProperties.push_back(jprop);
}
}
}
if (!keyFound)
{
m_arguments.push_back(argument);
// setProperty(KEY_ARGUMENTS, getProperty(KEY_ARGUMENTS) + " " + StringUtils::requoteForCommandLine(StringUtils::escape(argument)) );
}
}
std::vector<std::string> ResourceManager::getArguments()
{
return m_arguments;
}
int ResourceManager::getResourceSize(int id)
{
std::string propid = idToResourceName(id);
HRSRC resprop = FindResource(NULL, propid.c_str(), m_resourceCategory.c_str());
if (resprop != NULL)
{
return SizeofResource(NULL, resprop);
}
else
return 0;
}
HGLOBAL ResourceManager::getResource(int id)
{
std::string propid = idToResourceName(id);
HRSRC resprop = FindResource(NULL, propid.c_str(), m_resourceCategory.c_str());
if (resprop != NULL)
{
return LoadResource(NULL, resprop);
}
else
return 0;
}
std::string ResourceManager::saveJnismoothInTempFile()
{
if (m_jnismoothHandler == 0)
{
DEBUG("NO JNI SMOOTH ID !!");
return "";
}
std::string tempfilename = FileUtils::createTempFileName(".jar");
DEBUG("Saving jnismoothjar in " + tempfilename);
DEBUG("Created temporary filename to hold the jar (" + tempfilename + ")");
saveTemp(tempfilename, m_jnismoothHandler, m_jnismoothSize);
return tempfilename;
}

View File

@ -0,0 +1,198 @@
/*
JSmooth: a VM wrapper toolkit for Windows
Copyright (C) 2003-2007 Rodrigo Reyes <reyes@charabia.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef RESOURCEMANAGER_H
#define RESOURCEMANAGER_H
#include <cstdio>
#include <windows.h>
#include <string>
#include <vector>
#include "common.h"
#include "Properties.h"
#include "FileUtils.h"
#include "JavaProperty.h"
/**
* Manages the executable resources associated to a Java
* application. This class manages the resources that are used to
* store the data associated to a java application. Those resources
* are:
* - The JAR file, stored as a raw resource.
* - The Property file, stored as a raw resource.
*
* The Property file contains an 8-bit text, as parsed and used by the
* Properties class, which defines information relative to the java
* application (for instance the name of the main class, the java
* properties, and so on).
*
* @author Rodrigo Reyes <reyes@charabia.net>
*/
class ResourceManager
{
private:
std::string m_mainName;
std::string m_resourceCategory;
Properties m_props;
std::string m_currentDirectory;
int m_resourcePropsId;
int m_resourceJarId;
std::string m_lastError;
HGLOBAL m_jarHandler;
int m_jarSize;
HGLOBAL m_jnismoothHandler;
int m_jnismoothSize;
std::vector<std::string> m_arguments;
std::vector<std::string> m_deleteOnFinalize;
std::vector<JavaProperty> m_javaProperties;
public:
static char * const KEY_MAINCLASSNAME;
static char * const KEY_ARGUMENTS;
static char * const KEY_CLASSPATH;
static char * const KEY_JVMSEARCH;
static char * const KEY_MINVERSION;
static char * const KEY_MAXVERSION;
static char * const KEY_NOJVMMESSAGE;
static char * const KEY_NOJVMURL;
static char * const KEY_BUNDLEDVM;
static char * const KEY_CURRENTDIR;
static char * const KEY_EMBEDJAR;
/**
* Constructs a ResourceManager which extract the jar and property
* files from the resources defined by the given parameters. The
* resource are loaded from the resource type and resource names
* passed as parameters.
*
* @param category the resource type to look in
* @param propsId the resource id, stored under the category type, for the property file
* @param jarId the resource id, stored under the category type, for the jar file
*/
ResourceManager(std::string category, int propsId, int jarId, int jniId = -1);
/**
* Default destructor. The detructor tries to delete all the
* temporary files that have been created by the object. This is
* mainly the files created by the saveJarInTempFile() method.
*
* @sa ResourceManager::saveJarInTempFile
*/
~ResourceManager();
/** Saves the jar in a temporary folder. Extract the jar file
* from the resource defined in the consructor, and saves it in
* the temporary directory defined by the operating system.
*
* NOTE: if the KEY_EMBEDJAR key does not return "true", this method
* does not save the jar, and returns an empty string ("").
*
* @return the filename of the temp file where the Jar can be found.
*/
std::string saveJarInTempFile();
std::string saveJnismoothInTempFile();
/** Returns the name of the main class. The main class is the
* class used to launch the java application. The static "public
* void main(String[])" method of this class is called to start
* the program.
*
* @return the name of the main class
*/
std::string getMainName() const;
/**
* Returns the last error string. This is the string that describes
* the last error that was raised by an operation on the object.
* @return a string
*/
std::string getLastErrorString()
{
return m_lastError;
}
/**
* Retrieves a property value from the Properties resource defined
* in the constructor.
*
* @param key the name of the property
* @return a string that contains the value of the property, or an empty string if the property does not exist.
*/
std::string getProperty(const std::string& key) const;
std::string getProperty(const std::string& key, const std::string& def) const;
bool getBooleanProperty(const std::string& key) const;
/**
* Adds a new property.
*
* @param key the name of the property
* @param value the value associated to the property
*/
void setProperty(const std::string& key, const std::string& value);
std::vector<std::string> getNormalizedClassPathVector() const;
std::string getNormalizedClassPath() const;
/**
* Return the list of JavaProperty elements defined in the property
* resource.
*
* @return a vector of JavaProperty elements, or an empty vector if none are defined.
*/
const vector<JavaProperty>& getJavaProperties();
std::string getCurrentDirectory() const;
bool useEmbeddedJar() const;
void printDebug() const;
void setUserArguments(std::vector<std::string> arguments);
void addUserArgument(std::string argument);
std::vector<std::string> getArguments();
int getResourceSize(int id);
HGLOBAL getResource(int id);
private:
void saveTemp(std::string tempname, HGLOBAL data, int size);
std::string idToResourceName(int id) const
{
char buffer[32];
sprintf(buffer, "%d", id);
std::string result("#");
result += buffer;
return result;
}
};
#endif

View File

@ -119,6 +119,15 @@ bool SunJVMDLL::instanciate()
bool SunJVMDLL::setupVM12DLL(CreateJavaVM_t CreateJavaVM, GetDefaultJavaVMInitArgs_t GetDefaultJavaVMInitArgs)
{
vector<string> jpropstrv;
if (m_vmParameter != "")
{
std::vector<std::string> vmParameter = StringUtils::split(m_vmParameter, " ", " ", false);
for (std::vector<std::string>::iterator i=vmParameter.begin(); i != vmParameter.end(); i++)
{
jpropstrv.push_back(*i);
}
}
for (int i=0; i<m_properties.size(); i++)
if(m_properties[i].getName()[0]=='-') {
jpropstrv.push_back( StringUtils::requoteForCommandLine(m_properties[i].getName()));

View File

@ -50,7 +50,16 @@ bool SunJVMExe::run(const std::string& mainclass, bool useconsole)
execv.push_back(StringUtils::requoteForCommandLine(lookUpExecutable(useconsole)));
if (m_maxHeap > 0)
if (m_vmParameter != "")
{
std::vector<std::string> vmParameter = StringUtils::split(m_vmParameter, " ", " ", false);
for (std::vector<std::string>::iterator i=vmParameter.begin(); i != vmParameter.end(); i++)
{
execv.push_back(*i);
}
}
if (m_maxHeap > 0)
{
if ((m_version.getMajor()==1)&&(m_version.getMinor()==1))
execv.push_back("-mx" + StringUtils::toString(m_maxHeap));
@ -70,7 +79,7 @@ bool SunJVMExe::run(const std::string& mainclass, bool useconsole)
if(m_properties[i].getName()[0]=='-') {
execv.push_back( StringUtils::requoteForCommandLine(m_properties[i].getName()));
} else {
execv.push_back( StringUtils::requoteForCommandLine("-D" + m_properties[i].getName()) + "=" + StringUtils::requoteForCommandLine(m_properties[i].getValue()));
execv.push_back( StringUtils::requoteForCommandLine("-D" + m_properties[i].getName()) + "=" + StringUtils::requoteForCommandLine(m_properties[i].getValue()));
}
std::string classpath;

View File

@ -0,0 +1,233 @@
/*
JSmooth: a VM wrapper toolkit for Windows
Copyright (C) 2003-2007 Rodrigo Reyes <reyes@charabia.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "SunJVMLauncher.h"
#include "Process.h"
#include "SunJVMDLL.h"
#include "JArgs.h"
#include "JClassProxy.h"
extern "C" {
static jint JNICALL myvprintf(FILE *fp, const char *format, va_list args)
{
DEBUG("MYPRINTF");
}
void JNICALL myexit(jint code)
{
DEBUG("EXIT CALLED FROM JVM DLL");
exit(code);
}
}
std::string SunJVMLauncher::toString() const
{
return "<" + JavaHome + "><" + RuntimeLibPath + "><" + VmVersion.toString() + ">";
}
bool SunJVMLauncher::run(ResourceManager& resource, const string& origin, bool justInstanciate)
{
DEBUG("Running now " + this->toString() + ", instanciate=" + (justInstanciate?"yes":"no"));
Version max(resource.getProperty(ResourceManager:: KEY_MAXVERSION));
Version min(resource.getProperty(ResourceManager:: KEY_MINVERSION));
// patch proposed by zregvart: if you're using bundeled JVM, you
// apriori know the version bundled and we can trust. The version
// check is therefore unrequired.
if (origin != "bundled") {
if (VmVersion.isValid() == false)
{
DEBUG("No version identified for " + toString());
SunJVMExe exe(this->JavaHome);
VmVersion = exe.guessVersion();
DEBUG("Version found: " + VmVersion.toString());
}
if (VmVersion.isValid() == false)
{
DEBUG("No version found, can't instanciate DLL without it");
return false;
}
if (min.isValid() && (VmVersion < min))
return false;
if (max.isValid() && (max < VmVersion))
return false;
}
DEBUG("Launching " + toString());
//
// search for the dll if it's not set in the registry, or if the
// file doesn't exist
//
if ( (this->JavaHome.size()>0)
&& ((this->RuntimeLibPath.size() == 0) || (!FileUtils::fileExists(this->RuntimeLibPath))) )
{
std::string assump = FileUtils::concFile(this->JavaHome, "jre\\bin\\jvm.dll");
std::string assump2 = FileUtils::concFile(this->JavaHome, "jre\\bin\\server\\jvm.dll"); // for JRE 1.5+
std::string assump3 = FileUtils::concFile(this->JavaHome, "jre\\bin\\client\\jvm.dll"); // for JRE 1.5+
std::string assump4 = FileUtils::concFile(this->JavaHome, "bin\\javai.dll"); // For JRE 1.1
if (FileUtils::fileExists(assump))
this->RuntimeLibPath = assump;
else if (FileUtils::fileExists(assump2))
this->RuntimeLibPath = assump2;
else if (FileUtils::fileExists(assump3))
this->RuntimeLibPath = assump3;
else if (FileUtils::fileExists(assump4))
this->RuntimeLibPath = assump4;
else
{
vector<string> dlls = FileUtils::recursiveSearch(this->JavaHome, string("jvm.dll"));
if (dlls.size() > 0)
this->RuntimeLibPath = dlls[0];
}
}
if (FileUtils::fileExists(this->RuntimeLibPath))
{
DEBUG("RuntimeLibPath used: " + this->RuntimeLibPath);
Version v = this->VmVersion;
if (!v.isValid())
{
v = min;
if (!v.isValid())
v = Version("1.2.0");
DEBUG("No version, trying with " + v.toString());
}
m_dllrunner = new SunJVMDLL(this->RuntimeLibPath, v);
// set up the vm parameters...
setupVM(resource, m_dllrunner);
if (justInstanciate)
return m_dllrunner->instanciate();
else
return m_dllrunner->run(resource.getProperty(ResourceManager::KEY_MAINCLASSNAME),
true);
}
return false;
}
bool SunJVMLauncher::runProc(ResourceManager& resource, bool useConsole, const string& origin)
{
std::string classname = resource.getProperty(string(ResourceManager::KEY_MAINCLASSNAME));
if (VmVersion.isValid() == false)
{
DEBUG("No version identified for " + toString());
SunJVMExe exe(this->JavaHome);
VmVersion = exe.guessVersion();
DEBUG("Version found: " + VmVersion.toString());
}
if (VmVersion.isValid() == false)
return false;
if (origin != "bundled") {
Version max(resource.getProperty(ResourceManager:: KEY_MAXVERSION));
Version min(resource.getProperty(ResourceManager:: KEY_MINVERSION));
if (min.isValid() && (VmVersion < min))
return false;
if (max.isValid() && (max < VmVersion))
return false;
}
SunJVMExe exe(this->JavaHome, VmVersion);
setupVM(resource, &exe);
if (exe.run(classname, useConsole))
{
m_exitCode = exe.getExitCode();
return true;
}
return false;
}
bool SunJVMLauncher::setupVM(ResourceManager& resource, JVMBase* vm)
{
//
// create the properties array
const vector<JavaProperty>& jprops = resource.getJavaProperties();
for (int i=0; i<jprops.size(); i++)
{
vm->addProperty(jprops[i]);
}
if (resource.getProperty("maxheap") != "")
vm->setMaxHeap( StringUtils::parseInt(resource.getProperty("maxheap") ));
if (resource.getProperty("initialheap") != "")
vm->setInitialHeap( StringUtils::parseInt(resource.getProperty("initialheap") ));
if (resource.getProperty("vmparameter") != "")
vm->setVmParameter( resource.getProperty("vmparameter") );
if (resource.useEmbeddedJar())
{
std::string embj = resource.saveJarInTempFile();
vm->addPathElement(embj);
}
std::string jnijar = resource.saveJnismoothInTempFile();
if (jnijar != "")
vm->addPathElement(jnijar);
//
// Define the classpath
std::vector<std::string> classpath = resource.getNormalizedClassPathVector();
for (int i=0; i<classpath.size(); i++)
{
vm->addPathElement(classpath[i]);
}
//
// Defines the arguments passed to the java application
// vm->setArguments(resource.getProperty(ResourceManager::KEY_ARGUMENTS));
std::vector<std::string> args = resource.getArguments();
for (int i=0; i<args.size(); i++)
{
vm->addArgument(args[i]);
}
}
SunJVMDLL* SunJVMLauncher::getDLL()
{
return m_dllrunner;
}
bool operator < (const SunJVMLauncher& v1, const SunJVMLauncher& v2)
{
return v1.VmVersion < v2.VmVersion;
}
int SunJVMLauncher::getExitCode()
{
return m_exitCode;
}

View File

@ -0,0 +1,131 @@
/*
JSmooth: a VM wrapper toolkit for Windows
Copyright (C) 2003-2007 Rodrigo Reyes <reyes@charabia.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __VERSION_H_
#define __VERSION_H_
#include <cstdio>
#include <string>
#include "common.h"
#include "StringUtils.h"
/**
* Manages versions as used by Sun's JVM. The version scheme used is
* major.minor.sub, for instance 1.1.8 or 1.4.2.
*
* @author Rodrigo Reyes <reyes@charabia.net>
*/
class Version
{
private:
int m_major;
int m_minor;
int m_sub;
public:
std::string Value;
/**
* Creates a Version object from a string representation. This
* string needs to start as a normal version, but don't need to
* follow exactly the schema X.Y.Z. The Major number is mandatory,
* but the Minor and Sub numbers are optional.
*
* If the string representation does not represent a valid
* version, the object is said 'invalid', and returns false to the
* isInvalid() method.
*
* @param val a string representation of the version.
*/
Version(std::string val);
/**
* Creates an invalid Version object. The object created returns
* false to the isValid() method.
*/
Version();
/**
* Returns the major number of this Version.
*/
int getMajor() const;
/**
* Returns the minor number of this Version.
*/
int getMinor() const;
/**
* Returns the subminor number of this Version.
*/
int getSubMinor() const;
std::string toString() const;
// bool operator > (const Version& v) const;
friend bool operator < (const Version& v1, const Version& v2);
friend bool operator <= (const Version& v1, const Version& v2);
/**
* A version object may be invalid if it does not refer to a valid
* version. In such a case, the behaviour of object the is altered
* as follows:
*
* - The getMajor(), getMinor(), and getSubMinor() methods return 0
* - Any comparison (< or <=) between an invalid Version object
* and another object (invalid or not) return true.
*/
bool isValid() const;
private:
void parseValue(const std::string& val);
int extractIntAt(const std::string& val, int pos) const;
public:
struct AscendingSort
{
bool operator()(const Version& v1, const Version& v2)
{
if (v1.getMajor() > v2.getMajor())
return true;
if (v1.getMajor() < v2.getMajor())
return false;
if (v1.getMinor() > v2.getMinor())
return true;
if (v1.getMinor() < v2.getMinor())
return false;
if (v1.getSubMinor() > v2.getSubMinor())
return true;
if (v1.getSubMinor() < v2.getSubMinor())
return false;
return false;
}
};
};
#endif

View File

@ -0,0 +1,32 @@
# Project: ConsoleWrapper
# Makefile created by Dev-C++ 4.9.8.0
RM = rm -f
CPP = ${MINGW}/bin/${TARGET}-g++.exe
CC = ${MINGW}/bin/${TARGET}-gcc.exe
WINDRES = windres.exe
RES = ConsoleWrapper_private.res
OBJ = main.o $(RES)
LINKOBJ = main.o $(RES)
LIBS = -static-libgcc -L"${MINGW}/lib" -L"../commonjava" -L"../util-core" ../commonjava/CommonJava.a ../util-core/util-core.a
INCS = -I"/include" -I"../commonjava" -I"$(JDK)/include" -I"$(JDK)/include/win32"
CXXINCS = -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" -I"../commonjava" -I"../util-core" -I"../util-net" $(FLTK-CXXFLAGS)
BIN = ConsoleWrapper.exe
CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)"
CFLAGS = $(INCS)
.PHONY: all all-before all-after clean clean-custom
all: all-before ConsoleWrapper.exe all-after
clean: clean-custom
$(RM) $(OBJ) $(BIN) ConsoleWrapper_private.res
$(BIN): $(LINKOBJ) ../commonjava/CommonJava.a
$(CPP) $(LINKOBJ) -o "ConsoleWrapper.exe" $(LIBS)
main.o: main.cpp
$(CPP) -c main.cpp -o main.o $(CXXFLAGS)
ConsoleWrapper_private.res: ConsoleWrapper_private.rc mainres.rc
$(WINDRES) -i ConsoleWrapper_private.rc -J rc -o ConsoleWrapper_private.res -O coff

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<jsmoothskeleton>
<debug>false</debug>
<description>SKEL_CONSOLEWRAPPER_DESCRIPTION</description>
<executableName>consolewrapper.exe</executableName>
<resourceCategory>JAVA</resourceCategory>
<resourceJarId>102</resourceJarId>
<resourcePropsId>103</resourcePropsId>
<shortName>Console Wrapper x64</shortName>
<skeletonProperties>
<description>SKEL_CUSTOMWRAPPER_PROPERTY_MESSAGE_DESCRIPTION</description>
<idName>Message</idName>
<label>SKEL_CUSTOMWRAPPER_PROPERTY_MESSAGE_LABEL</label>
<type>textarea</type>
<value>This program needs Java to run.
Please download it at http://www.java.com</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_CUSTOMWRAPPER_PROPERTY_KEYPRESS_DESCRIPTION</description>
<idName>PressKey</idName>
<label>SKEL_CUSTOMWRAPPER_PROPERTY_KEYPRESS_LABEL</label>
<type>boolean</type>
<value>0</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_GENERIC_PROPERTY_DEBUG_DESCRIPTION</description>
<idName>Debug</idName>
<label>SKEL_GENERIC_PROPERTY_DEBUG_LABEL</label>
<type>boolean</type>
<value>0</value>
</skeletonProperties>
</jsmoothskeleton>

View File

@ -0,0 +1,8 @@
#include "resource.h"
JARID JAVA "samplejar/sample.jar"
PROPID JAVA "samplejar/sample.props"
A2 ICON MOVEABLE PURE LOADONCALL DISCARDABLE "JWrap.ico"
1 MANIFEST "../samplejar/sample.manifest"

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32"
name="myOrganization.myDivision.mySampleApp"
version="0.0.0.0"
processorArchitecture="ia64/x86"
/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View File

@ -0,0 +1,32 @@
# Project: JWrap
# Makefile created by Dev-C++ 4.9.8.0
CPP = ${MINGW}/bin/${TARGET}-g++.exe
CC = ${MINGW}/bin/${TARGET}-gcc.exe
WINDRES = windres.exe
RES = JWrap_private.res
OBJ = main.o $(RES)
LINKOBJ = main.o $(RES)
LIBS = -static-libgcc -L"${MINGW}/lib" -L"../commonjava" -L"../util-core" -mwindows ../commonjava/CommonJava.a ../util-core/util-core.a
INCS = -I"/include" -I"$(JDK)/include/win32" -I"$(JDK)/include" -I"../commonjava" -I"../util-core"
CXXINCS = -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" -I"../commonjava" -I"../util-core" -I"../util-net" $(FLTK-CXXFLAGS)
BIN = JWrap.exe
CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)"
CFLAGS = $(INCS)
.PHONY: all all-before all-after clean clean-custom
all: all-before JWrap.exe all-after
clean: clean-custom
$(RM) $(OBJ) $(BIN) JWrap_private.res
$(BIN): $(LINKOBJ) ../commonjava/CommonJava.a
$(CPP) $(LINKOBJ) -o "JWrap.exe" $(LIBS)
main.o: main.cpp
$(CPP) -c main.cpp -o main.o $(CXXFLAGS)
JWrap_private.res: JWrap_private.rc mainres.rc
$(WINDRES) -i JWrap_private.rc -J rc -o JWrap_private.res -O coff

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<jsmoothskeleton>
<debug>false</debug>
<description>SKEL_SIMPLEWRAPPER_DESCRIPTION</description>
<executableName>jwrap.exe</executableName>
<resourceCategory>JAVA</resourceCategory>
<resourceJarId>102</resourceJarId>
<resourcePropsId>103</resourcePropsId>
<shortName>Windowed Wrapper x64</shortName>
<skeletonProperties>
<description>SKEL_SIMPLEWRAPPER_PROPERTY_MESSAGE_DESCRIPTION</description>
<idName>Message</idName>
<label>SKEL_SIMPLEWRAPPER_PROPERTY_MESSAGE_LABEL</label>
<type>textarea</type>
<value>Java has not been found on your computer. Do you want to download it?</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_SIMPLEWRAPPER_PROPERTY_URL_DESCRIPTION</description>
<idName>URL</idName>
<label>SKEL_SIMPLEWRAPPER_PROPERTY_URL_LABEL</label>
<type>string</type>
<value>http://www.java.com</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_GENERIC_PROPERTY_SINGLEPROCESS_DESCRIPTION</description>
<idName>SingleProcess</idName>
<label>SKEL_GENERIC_PROPERTY_SINGLEPROCESS_LABEL</label>
<type>boolean</type>
<value>0</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_GENERIC_SINGLEINSTANCE_DESCRIPTION</description>
<idName>SingleInstance</idName>
<label>SKEL_GENERIC_SINGLEINSTANCE</label>
<type>boolean</type>
<value>0</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_GENERIC_JNISMOOTH_DESCRIPTION</description>
<idName>JniSmooth</idName>
<label>SKEL_GENERIC_JNISMOOTH</label>
<type>boolean</type>
<value>0</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_GENERIC_PROPERTY_DEBUG_DESCRIPTION</description>
<idName>Debug</idName>
<label>SKEL_GENERIC_PROPERTY_DEBUG_LABEL</label>
<type>boolean</type>
<value>0</value>
</skeletonProperties>
</jsmoothskeleton>

View File

@ -0,0 +1,8 @@
#include "resource.h"
JARID JAVA "../samplejar/sample.jar"
PROPID JAVA "../samplejar/sample.props"
JNISMOOTHID JAVA "../jnismooth/jnismooth.jar"
A2 ICON MOVEABLE PURE LOADONCALL DISCARDABLE "JWrap.ico"
1 MANIFEST "../samplejar/sample.manifest"

View File

@ -0,0 +1,211 @@
/*
JSmooth: a VM wrapper toolkit for Windows
Copyright (C) 2003-2007 Rodrigo Reyes <reyes@charabia.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "FileUtils.h"
string FileUtils::createTempFileName(const string& suffix)
{
char temppath[512];
int tplen = GetTempPath(512, temppath);
int counter = 0;
string temp;
do {
temp = string(temppath) + "temp" + StringUtils::toString(counter) + suffix;
counter ++;
} while (GetFileAttributes(temp.c_str()) != 0xFFFFFFFF);
return temp;
}
bool FileUtils::fileExists(const string& filename)
{
if (filename[0] == '"')
{
string unquoted = StringUtils::replace(filename, "\"", "");
return GetFileAttributes(unquoted.c_str()) != 0xFFFFFFFF;
}
return GetFileAttributes(filename.c_str()) != 0xFFFFFFFF;
}
bool FileUtils::fileExists(const std::string& path, const std::string& filename)
{
std::string f = FileUtils::concFile(path, filename);
return fileExists(f);
}
vector<string> FileUtils::recursiveSearch(const string& pathdir, const string& pattern)
{
vector<string> result;
string path = StringUtils::replace(pathdir, "\"", "");
WIN32_FIND_DATA data;
string file = path + ((path[path.length()-1]=='\\')?"":"\\") + pattern;
HANDLE handle = FindFirstFile(file.c_str(), &data);
if (handle != INVALID_HANDLE_VALUE)
{
result.push_back(path + ((path[path.length()-1]=='\\')?"":"\\") + data.cFileName);
for ( ; FindNextFile(handle, &data) == TRUE ; )
{
result.push_back(path + ((path[path.length()-1]=='\\')?"":"\\") + data.cFileName);
}
FindClose(handle);
}
handle = FindFirstFile((path + ((path[path.length()-1]=='\\')?"":"\\") + "*").c_str(), &data);
if (handle == INVALID_HANDLE_VALUE)
return result;
do {
string foundpath(data.cFileName);
if ((foundpath != ".") && (foundpath != "..") && ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0))
{
string npath = path + ((path[path.length()-1]=='\\')?"":"\\") + data.cFileName;
vector<string> tres = FileUtils::recursiveSearch(npath, pattern);
result.insert(result.end(), tres.begin(), tres.end());
}
} while (FindNextFile(handle, &data));
FindClose(handle);
return result;
}
std::string FileUtils::extractFileName(const std::string& filename)
{
int start = filename.rfind("\\", filename.length()-1);
if (start != filename.npos)
{
return filename.substr(start+1);
}
return filename;
}
std::string FileUtils::getExecutablePath()
{
char buffer[512];
GetModuleFileName(NULL, buffer, 512);
string full = buffer;
int pos = full.rfind('\\', full.npos);
return full.substr(0, pos+1);
}
std::string FileUtils::getExecutableFileName()
{
char buffer[512];
GetModuleFileName(NULL, buffer, 512);
string full = buffer;
int pos = full.rfind('\\', full.npos);
return full.substr(pos+1);
}
std::string FileUtils::getParent(const std::string &path)
{
if (path[path.length()-1] == '\\')
return getParent( path.substr(0, path.size() - 1) );
int pos = path.rfind('\\', path.npos);
if (pos != path.npos)
return path.substr(0, pos+1);
else
return path;
}
std::string FileUtils::getComputerName()
{
char buffer[MAX_COMPUTERNAME_LENGTH + 1];
DWORD size = MAX_COMPUTERNAME_LENGTH+1;
GetComputerName(buffer, &size);
return buffer;
}
std::string FileUtils::concFile(std::string path, std::string file)
{
if (FileUtils::isAbsolute(file))
return file;
if (path.length() > 0)
{
if (path[path.length()-1] != '\\')
path += '\\';
}
path += file;
return path;
}
std::string FileUtils::getFileExtension(const std::string& filename)
{
int pos = filename.rfind('.');
if (pos != std::string::npos)
{
return filename.substr(pos+1);
}
return "";
}
bool FileUtils::isAbsolute(const std::string& filename)
{
if (((filename.length()>2) && (filename[1] == ':') && (filename[2] =='\\')) || ((filename.length() >2) && (filename[0] == '\\') && (filename[1]=='\\')))
return true;
return false;
}
void FileUtils::deleteOnReboot(std::string file)
{
MoveFileEx(file.c_str(), 0, MOVEFILE_DELAY_UNTIL_REBOOT);
}
std::string FileUtils::readFile(const std::string& filename)
{
HANDLE f = CreateFile(filename.c_str(), GENERIC_READ,
FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
std::string result;
if (f != INVALID_HANDLE_VALUE)
{
char buffer[129];
DWORD hasread;
buffer[127] = 0;
do {
ReadFile(f, buffer, 127, &hasread, NULL);
buffer[hasread] = 0;
result += buffer;
} while (hasread > 0);
CloseHandle(f);
}
else
{
// printf("Can't open file %s\n",filename.c_str());
}
return result;
}

View File

@ -0,0 +1,127 @@
/*
JSmooth: a VM wrapper toolkit for Windows
Copyright (C) 2003-2007 Rodrigo Reyes <reyes@charabia.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __FILEUTILS_H_
#define __FILEUTILS_H_
#include <windows.h>
#include <string>
#include <vector>
#include "StringUtils.h"
using namespace std;
/** File access utility class.
* This class contains static class members that provide facilities
* for manamement of files.
*
* @author Rodrigo Reyes <reyes@charabia.net>
*/
class FileUtils
{
public:
/**
* Creates a temp filename. This method builds a temporary file
* name in the default windows temporary directory.
*
* @param suffix the suffix to use for the filename.
*/
static string createTempFileName(const string& suffix);
/**
* Test wether a file exists.
* @param filename the file name to check.
* @return true if the file exists, false otherwise.
*/
static bool fileExists(const string& filename);
static bool fileExists(const std::string&path, const string& filename);
/**
* Lookup recursively for files matching a given pattern in a given
* path. The method scans all the directory provided and its
* subdirectories. Each file matching the pattern is added to the
* resulting vector of strings.
*
* @param path the path of the directory to scan.
* @param pattern the file pattern, for instance "*.zip".
* @return a vector of string that contains the result.
*/
static vector<string> recursiveSearch(const string& path, const string& pattern);
/**
* Extracts the file part of a file path. Given a path of the form
* c:\\a\\b\\c\\d or c\\d, return the last component of the file path
* (that is, d in the previous example).
*
* @param filename an absolute or relative filename.
* @return a string with the file part of the file.
*/
static std::string extractFileName(const std::string& filename);
/**
* Returns the path where the executable application is executed
* from. This is not the current directory, but the directory path
* where the application was found. For instance if the application
* was runned at c:\\programs\\bin\\test.exe, it returns
* c:\\programs\\bin\\.
*
* @return a std::string text that holds the path.
*/
static std::string getExecutablePath();
static std::string getParent(const std::string &path);
/**
* Returns the name of the executable binary that was used to start
* the application.For instance if the application
* was runned at c:\\programs\\bin\\test.exe, it returns
* test.exe
*
* @return the executable name.
*/
static std::string getExecutableFileName();
/**
* Returns the name of the computer.
* @return a std::string that holds the computer name.
*/
static std::string getComputerName();
static std::string concFile(std::string path, std::string file);
static std::string getFileExtension(const std::string& filename);
static bool isAbsolute(const std::string& filename);
static std::string readFile(const std::string& filename);
static void deleteOnReboot(std::string file);
};
#endif

View File

@ -0,0 +1,32 @@
# Project: util-core
PROJECTNAME=util-core
RM = rm -f
CPP = ${MINGW}/bin/${TARGET}-g++.exe
CC = ${MINGW}/bin/${TARGET}-gcc.exe
WINDRES = windres.exe
MINGW =
RES =
OBJ = SingleInstanceManager.o Process.o Log.o Thread.o FileUtils.o StringUtils.o DebugConsole.o $(RES)
LIBS = -static-libgcc -L"$(MINGW)/lib"
INCS = -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32"
CXXINCS = -Os -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32"
BIN = $(PROJECTNAME).a
CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)"
CFLAGS = $(INCS)
.PHONY: all all-before all-after clean clean-custom $(PROJECTNAME)
all: all-before $(PROJECTNAME).a testmain.cpp all-after
clean: clean-custom
$(RM) $(OBJ) $(BIN) testmain.o test.exe
$(BIN): $(OBJ)
ar r $(BIN) $(OBJ)
ranlib $(BIN)
$(CPP) $(OBJ) testmain.o -o test.exe $(LIBS)
$(PROJECTNAME).a: $(OBJ) testmain.o

View File

@ -0,0 +1,163 @@
/*
JSmooth: a VM wrapper toolkit for Windows
Copyright (C) 2003-2007 Rodrigo Reyes <reyes@charabia.net>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __STRINGUTILS_H_
#define __STRINGUTILS_H_
#include <cstdio>
#include <string>
#include <vector>
#include <windows.h>
using namespace std;
/**
* Provides basic string operations.
*
* @author Rodrigo Reyes <reyes@charabia.net>
*/
class StringUtils
{
public:
/**
* Splits a string in several substrings. The split method takes a
* string as input, and outputs a vector of string. The string split
* is done according to 2 parameters:
*
* - the separators parameter, defines which chars are
* separators. Typically, this is a string that contains spaces,
* line-feed, and tabulation chars (" \n\t").
*
* - the quotechars parameter, is useful when your input contains
* quoted string that should not be broken down into substrings. For
* instance, a typical quote char is a quote or a double quote
* (resp. ' and ").
*
* For example, is the input string is the line belows:
* - this is "my string" and this is 'another one'.
*
* Here is the result of the call with the following parameters:
* - separators = \\n\\r\\t
* - quotechars = \\"\\'
*
* The output string is:
* - this
* - is
* - my string
* - and
* - this
* - is
* - another one
*
* @param str the string to be splitted
* @param separators a string that contains all the characters to be used as separators.
* @param quotechars a string that contains all the characters that are used as quote chars.
*/
static vector<string> split(const string& str, const string& separators, const string& quotechars, bool handleEscape = true, bool returnSeparators = false);
/**
* Converts a string to an int. If the string is not a valid
* integer, it returns 0.
*
* @param val the string to parse
* @return an integer value
*/
static int parseInt(const string& val);
static int parseHexa(const string& val);
/**
* Convers an integer to a string.
*
* @param val an integer
* @return a string
*/
static string toString(int val);
static string toHexString(int val);
/**
* Provides a string representation of a vector of string. A vector
* that contains 2 string aaa and bbb is represented as follows:
* [aaa, bbb].
*
* @param seq a vector of string
* @return a string representation
*/
static string toString(const vector<string>& seq);
/**
* Copies the content of a string in a char array.
*
* @param from the string to copy from
* @param to the destination array of chars
* @param length the length of the array of char
*/
static void copyTo(const string& from, char* to, int length);
/**
* Returns a copy of the string with the environment variables
* replaced. The environment variable must be surrounded by %
* signs. For each variable defined between 2 % signs, the method
* tries to replace it by the value of the corresponding environment
* variable. If no variable exists, it just replaces it with an
* empty string.
*
* @param str the string to transform
* @return the same string, but with all the environment variable replaced
*/
static string replaceEnvironmentVariable(const string& str);
static string replace(const string& str, const string& pattern, const string& replacement);
static string join(const vector<string>& seq, const string& separator);
static string trim(string& str);
/**
* If a string does not start with a quote ("), it returns a copy of
* the string with enclosing quotes.
*
* @param str a string
* @return a fixed copy of the string
*/
static std::string fixQuotes(const string& str);
static std::string escape(const string& str);
static std::string unescape(const string& str);
/**
* Ensures a string is correctly quoted, the quotes are enclosing
* the whole string, not a part of the string. For instance
* <<"c:\\my path"\\bin>> is transformed into <<"c:\\my path\\bin">>
*
* @param str a string
* @return a fixed copy of the string
*/
static std::string requote(const string& str);
static std::string requoteForCommandLine(const string& str);
static std::string toLowerCase(const string& str);
static std::string fixArgumentString(const std::string& arg);
static std::string sizeToJavaString(int size);
static std::string sizeToJavaString(std::string size);
};
#endif

View File

@ -0,0 +1,34 @@
# Project: CommonJava
PROJECTNAME=util-net
RM = rm -f
CPP = ${MINGW}/bin/${TARGET}-g++.exe
CC = ${MINGW}/bin/${TARGET}-gcc.exe
WINDRES = windres.exe
MINGW = "c:/MinGW"
FLTK-LDFLAGS = $(shell fltk-config --ldflags)
FLTK-CXXFLAGS = $(shell fltk-config --cxxflags)
RES =
OBJ = WinHttpClient.o HttpClient.o URL.o downloadgui.o httpdownload.o $(RES)
LIBS = -static-libgcc -L"$(MINGW)/lib" -lws2_32 -lwininet $(FLTK-LDFLAGS)
CXXINCS = -Os -I"../util-core" -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" $(FLTK-CXXFLAGS)
BIN = $(PROJECTNAME).a
CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)"
.PHONY: all all-before all-after clean clean-custom $(PROJECTNAME)
all: all-before $(PROJECTNAME).a testmain.cpp all-after
clean: clean-custom
$(RM) $(OBJ) $(BIN) test.exe testmain.o
$(BIN): $(OBJ)
ar r $(BIN) $(OBJ)
ranlib $(BIN)
$(CPP) -g $(OBJ) ../util-core/util-core.a testmain.o -o test.exe $(LIBS)
$(PROJECTNAME).a: $(OBJ) testmain.o
testmain.o: testmain.cpp
$(CPP) -c testmain.cpp -o testmain.o $(CXXFLAGS)

View File

@ -0,0 +1,33 @@
# Project: WinService Wrapper
# Makefile created by Dev-C++ 4.9.8.0
RM = rm -f
#cmd /C DEL
CPP = ${MINGW}/bin/${TARGET}-g++.exe
CC = ${MINGW}/bin/${TARGET}-gcc.exe
WINDRES = windres.exe
RES = winservice_private.res
OBJ = main.o $(RES)
LINKOBJ = WinService.o main.o $(RES)
LIBS = -static-libgcc -L"${MINGW}/lib" -L"../commonjava" -L"../util-core" ../commonjava/CommonJava.a ../util-core/util-core.a
INCS = -I"/include" -I"../util-core" -I"../commonjava" -I"$(JDK)/include" -I"$(JDK)/include/win32"
CXXINCS = -I"$(MINGW)/include/c++" -I"$(MINGW)/include/c++/mingw32" -I"$(MINGW)/include/c++/backward" -I"$(MINGW)/include" -I"$(JDK)/include" -I"$(JDK)/include/win32" -I"../commonjava" -I"../util-core" -I"../util-net" $(FLTK-CXXFLAGS)
BIN = winservice.exe
CXXFLAGS = $(CUSTOMFLAGS) $(CXXINCS) -DJDK="$(JDK)"
CFLAGS = $(INCS)
.PHONY: all all-before all-after clean clean-custom
all: all-before winservice.exe all-after
clean: clean-custom
$(RM) $(OBJ) $(BIN) winservice.o winservice_private.res
$(BIN): $(LINKOBJ) ../commonjava/CommonJava.a
$(CPP) $(LINKOBJ) -o "winservice.exe" $(LIBS)
main.o: main.cpp
$(CPP) -c main.cpp -o main.o $(CXXFLAGS)
winservice_private.res: winservice_private.rc mainres.rc
$(WINDRES) -i winservice_private.rc -J rc -o winservice_private.res -O coff

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<jsmoothskeleton>
<debug>false</debug>
<description>SKEL_WINSERVICE_DESCRIPTION</description>
<executableName>winservice.exe</executableName>
<resourceCategory>JAVA</resourceCategory>
<resourceJarId>102</resourceJarId>
<resourcePropsId>103</resourcePropsId>
<shortName>WinService Wrapper x64</shortName>
<skeletonProperties>
<description>SKEL_WINSERVICE_NAME_DESCRIPTION</description>
<idName>ServiceName</idName>
<label>SKEL_WINSERVICE_NAME_LABEL</label>
<type>string</type>
<value>myservice</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_WINSERVICE_DISPLAYNAME_DESCRIPTION</description>
<idName>ServiceDisplayName</idName>
<label>SKEL_WINSERVICE_DISPLAYNAME_LABEL</label>
<type>string</type>
<value>My Service</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_WINSERVICE_PROPERTY_MESSAGE_DESCRIPTION</description>
<idName>Message</idName>
<label>SKEL_WINSERVICE_PROPERTY_MESSAGE_LABEL</label>
<type>textarea</type>
<value>This program needs Java to run. Please download it at http://www.java.comf</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_WINSERVICE_AUTOSTART_DESCRIPTION</description>
<idName>Autostart</idName>
<label>SKEL_WINSERVICE_AUTOSTART_LABEL</label>
<type>boolean</type>
<value>1</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_WINSERVICE_LOGFILE_DESCRIPTION</description>
<idName>Logfile</idName>
<label>SKEL_WINSERVICE_LOGFILE_LABEL</label>
<type>string</type>
<value>service.log</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_WINSERVICE_INTERACTIVE_DESCRIPTION</description>
<idName>Interactive</idName>
<label>SKEL_WINSERVICE_INTERACTIVE_LABEL</label>
<type>boolean</type>
<value>0</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_GENERIC_JNISMOOTH_DESCRIPTION</description>
<idName>JniSmooth</idName>
<label>SKEL_GENERIC_JNISMOOTH</label>
<type>boolean</type>
<value>0</value>
</skeletonProperties>
<skeletonProperties>
<description>SKEL_GENERIC_PROPERTY_DEBUG_DESCRIPTION</description>
<idName>Debug</idName>
<label>SKEL_GENERIC_PROPERTY_DEBUG_LABEL</label>
<type>boolean</type>
<value>0</value>
</skeletonProperties>
</jsmoothskeleton>

View File

@ -0,0 +1,9 @@
#include "resource.h"
JARID JAVA "../samplejar/sample.jar"
PROPID JAVA "../samplejar/sample.props"
JNISMOOTHID JAVA "../jnismooth/jnismooth.jar"
A2 ICON MOVEABLE PURE LOADONCALL DISCARDABLE "JWrap.ico"
1 MANIFEST "../samplejar/sample.manifest"