Java Mailing List Archive

http://www.ant-tasks.com/

Apache Ant Archive

» Ant Users List
» Ant Developers List
Ant and the Windows Registry

Ant and the Windows Registry

2006-10-17       - By Robert Pepersack
Reply:     1     2     3     4     5     6     7     8     9     10     >>  

I tried the Java Preferences API, but it won't let you access registry
entries.  It will only let you read/write to registry entries that you
create specifically for your Java application, based on the Java
package.

So, I tried orangevolt, but I get this error:

BUILD FAILED
C:\MIAEnterpriseSystem\Delivery8.0\build.xml:40: taskdef A class needed
by class com.orangevolt.tools.ant.Win32ShortcutTask cannot be found:
com/roxes/win32/UrlFile

I tried taking Peter Kitt's advice by putting the
orangevolt-ant-tasks.jar file into %USERPROFILE%/.ant/lib.  But, no such
directory exists in my C:\Documents and Settings directory.  When I
tried to create the .ant directory, Windows 2000 gave me this error:  

You must type a filename.

So, I tried adding the orangevolt .jars to my classpath with no
success.  Here's the snippet from my build file:

   <path id="build.classpath">
       <pathelement location="${classes.dir}/easserver.jar" />
       <pathelement location="${classes.dir}/easj2ee.jar" />
       <pathelement location="${classes.dir}/easclient.jar" />
       <pathelement location="${classes.dir}/jconn2.jar" />
       <pathelement
location="${classes.dir}/orangevolt-ant-tasks-1.3.5.jar" />
       <pathelement
location="${classes.dir}/roxes-win32forjava-1.0.4.jar" />
       <pathelement location="${java.home}/lib/tools.jar" />
       <pathelement location="${classes.dir}" />
       <pathelement location="${src.dir}" />
   </path>

   <taskdef classpath="build.classpath"
resource="com/orangevolt/tools/ant/taskdefs.properties"/>
   <target name="orangevolt" description="Check for EAServer's
classpath">
       <!--
           Look for
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Jaguar/Parameters/CLASSPATH
       -->
       <win32.registry root="HKEY_LOCAL_MACHINE" key="SYSTEM">
           <exists property="test"
subkey="CurrentControlSet/Services/Jaguar/Parameters" entry="CLASSPATH"
/>
       </win32.registry>

       <echo message="test=${test}" />
   </target>

What am I doing wrong?

Thanks,

Bob

Robert Pepersack
Senior Lead Developer
Maryland Insurance Administration
410-468-2054

>>> peter.kitt.reilly@(protected) 10/13/2006 9:34:42 AM >>>
On 10/13/06, Robert Pepersack <RPepersack@(protected)>
wrote:
> Hi all,
>
> I would like to read and alter a Windows registry key with Ant.  You
> may ask why would I want to change the Windows registry??!!  I want
to
> change the registry because I want to change my J2EE server's
(Sybase
> EAServer) classpath from Ant.  My fellow developers and I could
change
> our servers' classpathes manually by opening regedit, but this would
be
> prone to point-and-click screw-ups.  I think that changing the
registry
> from Java would be more reliable and less error-prone.
>
> I Googled on the subject and found that there is a Java Preferences
API
> and Orangevolt Ant Tasks.  Has anyone used these, or know of
something
> better?
>
The orangevolt ant tasks look pretty nice. They include a jni dll
that accesses the win reg (why oh why did sun not support jdirect?)

On initial load, the tasks  copy the dll into $JAVA_HOME/jre/bin.
The tasks can then read and write reg entries.

Usage: drop the orangevolt-ant-tasks.jar file into
%USERPROFILE%/.ant/lib
and
use:
<project name="rox" default="main">
   <taskdef resource="com/orangevolt/tools/ant/taskdefs.properties"/>

 <target name="main">

   <win32.registry root="HKEY_LOCAL_MACHINE" key="SOFTWARE">
     <!--
          softwareExists will be set if
          HKEY_LOCAL_MACHINE\SOFTWARE exists
          -->
     <exists property="softwareExists"/>
   </win32.registry>

   <echo message="softwareExists=${softwareExists}"/>
 </target>
</project>

Peter


> Thanks,
>
> Bob
>
> Robert Pepersack
> Senior Lead Developer
> Maryland Insurance Administration
> 410-468-2054
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)


©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.