• Post Reply 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
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Creating JAR

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

I have posted this https://coderanch.com/t/303446/JDBC/java/Creating-JAR topic on the JDBC forum but could not get any help.

I have created a simple Java application (ReadingAccessDB) that reads table rows from MS Access database. The program packages the java class file in jdbc folder (package jdbc; ), and the database file is one level up.

here is the code:



For example if the class file is in C:\jdbc\ReadingAccessDB.class, the database file "carpets.mdb" is in C:\

when using JVM "C:\java jdbc.ReadingAccessDB", the application works fine. However, I want to archive the application with the database file in a jar file so that it can be executed from any location. Could some one help

Alqtn

[ January 26, 2006: Message edited by: A Alqtn ]

[ January 26, 2006: Message edited by: A Alqtn ]
[ January 26, 2006: Message edited by: A Alqtn ]
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think using ANT you can solve it.
As you know using build file can make use of jar file.

Here is a sample program in ANT. I am just tyring, it is not sure. Anyway try...

Description:

Here I have a file called "Hello.java" and it is inside "D:\AnT".
So change it with your file name and directory path to the specified file.

create a build file using this and

1) type -> ant compile
2) type -> ant jar
3) type -> ant run

or replace all with

ant compile jar run

Code is:


<project>

<target name="clean">
<delete dir="build"/>
</target>

<target name="compile">
<mkdir dir="build/classes"/>
<javac srcdir="D:\AnT" destdir="build/classes"/>
</target>

<target name="jar">
<mkdir dir="build/jar"/>
<jar destfile="build/jar/Hello.jar" basedir="build/classes">
<manifest>
<attribute name="Main-Class" value="Hello"/>
</manifest>
</jar>
</target>


<target name="run">
<java jar="build/jar/Hello.jar" fork="true"/>
</target>

</project>

Note:
I am new to ANT, so please forgive me if any mistake
 
Ranch Hand
Posts: 381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well to confirm what was said in your other thread and what I am pretty sure I told you a few days ago on another forum.

You cannot do this. You cannot embed your Access database in a jar and access it with JDBC. There are a number of technical impossibilities that make this a non-starter. You will have to ship the database as a seperate file (although you could deploy in one setup or zip file) and have it reside in a proper Windows directory.

There is no workaround that will make this (Access) work directly from a Jar.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic