Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Creating a Jar with a recognizable properties file

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hello!

I have written a logic gate program that uses a properties file to essentially access the proper class (as part of an assignment). This is working fine. However, I am supposed to create a build.XML file that contains the information for the jar.

I have a sample program that my professor wrote that works fine. Mine does not. Therefore, I tried I copying and paste his over to mine (and change the appropriate words) mine does not work (as per his suggestion). More specifically, I am able to create the jar file, but after the main user interface loads, when I select something in it that needs the properties file it closes out. When I run it through Apache Ant, it says "Property file location not set. Passed in value is: null". The properties file is physically there (I have it copy to the build folder and I have double-checked that it is showing up in the jar as well.)

I had messed around with some of the Eclipse settings so I am worried I screwed something up there when my xml file is actually fine.

I have pasted my build.xml file underneath for your further information.

Any ideas?? I have spent nearly a week trying to get this to work!
-----------------------------------------------------------------------------------------------------------
<?xml version="1.0" ?>

<!--
logicgate Ant Build.xml file
-->

<project name="logicgate" basedir=".">
<property name="src.dir" value="${basedir}/src"/>
<property name="bin.dir" value="${basedir}/classes"/> <!-- NOTE: bin maps to classes in FleetRental!! -->
<property name="build.dir" value="${basedir}/build"/>
<property name="config.dir" value="${basedir}/config"/>
<property name="lib.dir" value="${basedir}/lib"/>

<!-- Classpath for the project -->
<path id="master-classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>

<!-- Cleanup and Dir Creation -->
<target name="clean" description="Deletes old and creates new classes, and build directories.">
<delete dir="${bin.dir}"/>
<mkdir dir ="${bin.dir}"/>
<delete dir="${build.dir}"/>
<mkdir dir ="${build.dir}"/>
</target>

<!-- Compiling Code -->
<target name="compile" description="Compiles code" depends="clean">
<javac srcdir="${src.dir}"
destdir="${bin.dir}">
<classpath refid="master-classpath"/>
</javac>
</target>

<!-- Build Jar -->
<target name="buildjar" depends="compile">
<jar jarfile="${build.dir}/logicgate.jar">
<fileset dir="${basedir}">
<include name="config/*"/>
</fileset>
<fileset dir="${bin.dir}">
<include name="**/*.class"/>
</fileset>
<manifest>
<attribute name="Main-Class" value="com.logicgate.view.presentation.MainUI"/>
</manifest>
</jar>

<!-- Copy the config folder over to the build folder: application needs this to load properties file-->
<copy todir="${build.dir}">
<fileset dir="${basedir}">
<include name="config*/**/*"/>
</fileset>
</copy>

</target>

<!-- Execute Jar -->
<target name="testjar" depends="buildjar">
<java jar="${build.dir}/logicgate.jar" fork="yes" dir=".">
</java>
</target>
</project>

 
Laura Perry
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
My professor pointed out my error!

Basically, I had been loading the properties file via a variable I had defined for runtime (the location of my properties file... -Dprops_location=C:...") but because I am now creating a jar, I had to go into one of my classes and change the location of the file to where it was within my project.

Oops!
 
It is an experimental device that will make my mind that most powerful force on earth! More powerful than this tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
    Bookmark Topic Watch Topic
  • New Topic