Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!
    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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Creating a Jar with a recognizable properties file

Posts: 2
  • Mark post as helpful
  • send pies
  • Report post to moderator

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"/>

<!-- 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}"/>

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

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

<!-- 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*/**/*"/>


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

Laura Perry
Posts: 2
  • Mark post as helpful
  • send pies
  • 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.

    Bookmark Topic Watch Topic
  • New Topic