JAR file including database connection

Hello,
I made an application ( GUI ) which uses a MS acces Database.
I used Netbeans, so a JAR file is automatically created.
The only problem is that when I run the Jar file ,the application isn't able to find the connection with the database.
Very annoying, but I do not know how to include it in my JAR file.
Is it possible? Maybe not, because access is from windows, while JAR is independent of the running platform.
If not, is it possible to make it run independently in another way, for example 'exe-file'.
If yes, how?Any ideas...
I've been looking for a couple of weeks, but never found a satisfying solution...
I just want to be able to run the application without the need of netbeans.
Thanks in advance.

Thx for your quick replies!
First of all , I will give you more details how I made connection with access. Beneath you find my class 'Database".
Then, I made an object from that class and use it for example createStatements:
{code}Statement stmt = db.getDbConnection().createStatement();{code} (db = object from class Database )
{code}package database;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class Database {
private Connection dbConnection;
public Database(String file) {
loadDriver();
connectDatabase(file);
private void loadDriver() {
try
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
catch (ClassNotFoundException err)
System.out.println("Could not load driver ");
System.exit(1);
private void connectDatabase(String dbFile) {
try
String protocol ="jdbc";
String subProtocol = "odbc";
String subName ="Driver={Microsoft Access Driver (*.mdb)};DBQ= "+dbFile;
String URL = protocol + ":" + subProtocol + ":" + subName;
     dbConnection = DriverManager.getConnection(URL);
catch(SQLException error)
System.err.println("Error connecting to database: " + error.toString());
public void closeConnection() {
try
dbConnection.close();
catch(SQLException error)
System.err.println("Cannot disconnect database");
public Connection getDbConnection(){
return dbConnection;
}{code}
You said that the resources have to exist when you run it...Okay. In netbeans that's easy because it's part of java language and netbeans loads everything he needs... But how can I realise it to run without netbeans?
Btw, it's no problem that the application is only runnable on windows. I was just wondering...
If you need some more information, just ask. It's not always easy for me to understand what information a specialist like you needs ;-)

Similar Messages

  • How can i include database connection in an EP development

    Does any body knows what are the steps to include database connection in an EP development in NWDS?

    Hi Jose.
    http://help.sap.com/saphelp_nw04/helpdata/en/30/a0f17aacb34b108b39a96acc33da3f/frameset.htm
    or
    http://help.sap.com/saphelp_nw04/helpdata/en/fe/9e362f3d954e8e8555007d8030df63/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/b0/6e62f30cbe9e44977c78dbdc7a6b27/frameset.htm
    Regards, Karsten

  • Where is the jar file includes ejb3.0 interface

    I just start using ejb 3.0, when i create a stateless session bean, i can not find the Stateless interface when import javax.ejb.Stateless. Appreciated if someone can let me which jar file includes those interface (like javax.ejb.Remove, javax.ejb.Stateful, etc.) and where to download?

    Hi,
    check jdeveloper_home\jdeveloper_10133_<version>\jlib\identitystore.jar
    Frank

  • Java application - build JAR file & include JCO library

    Hello everyone,
    I have a problem with my Java application that <i>connects to SAP system using JCO </i>library <b>(sapjco.jar)</b>.
    I would like to create a JAR file from my Java application but when I run the JAR file that I created I get an error that <b>NoClassDefinitionFoundError com/sap/mw/jco/JCO at [...]</b>
    That means that the JCO and associated DLL files <b>(sapjco.jar, librfc32.dll and sapjcorfc.dll)</b> were <u>not</u> included/packed in my JAR file.
    <b>-- How can I include the JCO lib in JAR file?
    -- If there is a problem with the DLL files, how can I include the JCO lib externally (dynamicly read the JCO whenever my JAR in run)?</b>
    I am using Eclipse 3.2 and Export to JAR option when I click right button on Project.
    THANKS IN ADVANCE FOR HELP!!!

    Hi,
    The problem is that you don't have defined the libraries in the Manifest file of your jar-file. So the jar doesn't know what to use at runtime.
    Add following entry to the MANIFEST.MF file:
    Class-Path:/<lib_folder>/<lib1_name>.jar; /<lib_folder>/<lib2_name>.jar and so on.
    Regards,
    Daniel

  • Problem while loading a jar file into database

    Hi All,
    We are using Oracle 8.1.5 in Solaris. When I try to load a jar file into the database by using loadjava it gives the following error
    Error while processing jar cryptix32.jar
    Exception java.io.IOException: Load Java is unable to handle compressed entries: cryptix/provider/Cryptix.class
    loadjava: 1 errors
    Can anybody suggest anything to overcome this. Thanks in advance.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by John Emmer ([email protected]):
    I presume you've tried creating the jar w/o compressing it? If not, and even if you didn't create the jar, then first unpack the jar into a directory and re-jar it without using compression.<HR></BLOCKQUOTE>
    Hi John,
    Thanks for your help. I unpacked the jar and rhen re-jared it with -0 (uncompress ) option. The above error is gone. But I am getting another problem. I am getting the following error for all the classes except the property files.
    Error while resolving class cryptix/cryptix/provider/cipher/Rijndael
    ORA-04043: object cryptix/cryptix/provider/cipher/Rijndael does not exist
    But the class is there in the jar. I am able to load single individual classes. Can anybody help me in this matter. Thanks in advance.

  • Creating jar file including 2 another jar files

    hi
    My project has java files, properties files,batch files as well as two jar files,mail.jar & activation.jar(for importing packages).
    I have to include these jar files while setting environment variables.
    Now i want to make "MyPrj.jar" file for myproject ,can anyone pls help me how to include these all files into a single jar file. and how to make setup file
    I have tried to extract out .class files of mail.jar & activation.jar & i ve created MyPrj.jar by including all class files(including class files of mail.jar & activation.jar) but manifest file(headers) are not added to MyPrj.jar.
    i have also tried to give mail.jar & activation.jar in Class-Path of menifest file, but it is also not working.
    Pls Help
    Thanks a lot

    [http://sourceforge.net/projects/one-jar]
    "One-JAR(TM) is a simple solution to a vexing problem in Java: how to distribute an application as a single jar-file, when it depends on multiple other jar-files. One-JAR uses a custom classloader to discover library jar files inside the main jar. "

  • Urgent: Does dbms_java package is required  to load jar file into database?

    Hi, It's a urgent request. I am trying to install jar file that was created by JDeveloper into database using loadjava. But it is giving so many errors.
    Do we need to install dbms_java package in order to load jar files into the database? Thanks.

    Thanks for your reply Kamal.
    I am trying to load these jar files into Oracle 9.2.0.3.20 database.
    Could you please give me the list of the steps to enable java within the database? Thanks.

  • Which jar file include class - weblogic.utils.UnsyncStringBuffer?

    When I compile my JSP file by using JDeveloper, but I got "Error: java.lang.NoClassDefFoundError: weblogic/utils/UnsyncStringBuffer". I don't know which jar file is including this class file, and where I can get that jar file?
    This is my JSP file header
    <%@page language="java" contentType="text/html;charset=UTF-8"%>
    <%@taglib uri="netui-tags-databinding.tld" prefix="netui-data"%>
    <%@taglib uri="netui-tags-html.tld" prefix="netui"%>
    <%@taglib uri="netui-tags-template.tld" prefix="netui-template"%>
    <%@taglib uri="cnt.tld" prefix="cnt" %>
    <%@taglib uri="cnt-util.tld" prefix="cnt-util" %>
    <%@taglib uri="c.tld" prefix="c"%>
    Thanks,
    lucy

    I doubt that a user who hasn't posted in 3+ years is going to wake up and answer you.
    Probably best for you to post your details in a new thread (linking to here if you think it adds value)
    You can always use Tools->Manage Libraries in JDeveloper and type the class name into the search box; it will tell you which libraries have the class.

  • ANT - Jar File include another Jar file and importing classes

    Here is the directory structure i have set up:
    FTPGetter
      \src
        \com
          \abc
            \ftpgetter
              - GUI.java
              - FTPGetter.java
              - Login.java
      \classes
      \include
        - ftpClient.jar
        - info.xml
      \jar
        - FTPGetter.jarThe code compiles file and can create a Jar file without errors. But when I execute the Jar file, I get
    java.lang.NoClassDefFoundError: com/abc/ftpclient/FTPwhich is a class that I import from the ftpClient.jar file in FTPGetter.java
    What gives?
    Here is my necessary build.xml code:
    <?xml version="1.0"?>
    <project name="FTPGetter" default="all">
      <property name="src.dir"        value="src"/>
      <property name="package.name"   value="com.abc.ftpgetter"/>
      <property name="package.dir"    value="${src.dir}/com/abc/ftpgetter"/>
      <property name="classes.dir"    value="classes"/>
      <property name="include.dir"    value="include"/>
      <property name="jar.dir"        value="jar"/>
      <property name="javadoc.dir"    value="docs"/>
      <property name="javadoc.title"  value="FTPGetter"/>
      <property name="javadoc.header" value="FTPGetter - By ABC XYZ [2005]"/>
      <property name="run.classname"  value="${package.name}.FTPGetter"/>
      <target name="init">
        <mkdir dir="${javadoc.dir}" />
        <mkdir dir="${classes.dir}" />
        <mkdir dir="${jar.dir}" />
      </target>
      <target name="all" depends ="compile,jar" />
      <target name="compile" description="Compile Java code" depends="clean, init">
        <javac srcdir="${package.dir}" destdir="${classes.dir}">
          <classpath>
            <!-- use the value of the ${classes.dir} property in the classpath -->
            <pathelement path="${classes.dir}" />
            <!-- include all jar files  -->
            <fileset dir="${include.dir}">
              <include name="**/*.jar"/>
            </fileset>
          </classpath>
        </javac>
      </target>
      <target name="clean" description="Clean up">
        <delete dir="${javadoc.dir}" />
        <delete dir="${classes.dir}" />
        <delete dir="${jar.dir}" />
      </target>
      <target name="jar" depends="compile">
        <jar jarfile="${jar.dir}/FTPGetter.jar" update="false">
          <fileset dir="${classes.dir}" includes="**/*.class" />
    <!-- Include xml file to read.-->
          <fileset dir="${include.dir}" includes="info.xml" />
    <!-- Include ftpClient in the jar file.-->
          <fileset dir="${include.dir}" includes="ftpClient.jar" />
          <manifest>
            <attribute name="Main-Class" value="com.abc.ftpgetter.FTPGetter" />
            <attribute name="Class-Path" value="include/ftpClient.jar"/>
          </manifest>
        </jar>
      </target>
    </project>

    nevermind I got that fixed now:
    had to get the build.xml code for the <target name="jar" depends="compile">so that it looks more like:
      <target name="jar" depends="compile">
        <jar jarfile="${jar.dir}/FTPGetter.jar">
          <zipfileset dir="classes" prefix="" />
          <zipfileset src="include/ftpClient.jar" />
          <zipfileset dir="${include.dir}" includes="info.xml" />
          <manifest>
            <attribute name="Main-Class" value="com.abc.ftpgetter.FTPGetter" />
          </manifest>
        </jar>
      </target>Keyword would need to be zipfileset.

  • How to compile jar file including all dependencies ?

    Hi all,
    I have an application with more than 50 classes that use third party libraries.
    I would like to compact everything in just one single jar file BUT just the classes I need, not the whole external libraries.
    Archive builder from JBuilder works pretty fine, but I need a command line tool to integrate this into an automatic compilation process from a bigger project.
    What can I use ?
    Thanks a lot!

    Yes, I can live with it but, I cannot
    believe
    that there is no any command line tool for doingwhat
    Archive Builder from Borland does !!I'd bet a year's salary that Archive Builder isn't
    foolproof anyway. When you consider classes may be
    instantiated dynamically thru reflection and so
    forth, there's no way any tool can really tell with
    100% certainty what all the dependencies are.But apart from dynamic class loading? I can manage dynamical loaded classes manually, but would be really helpful to have an automatic tool for including all 'static' dependecies.
    This is a common task in other programming languages. How to do this using standard (free?) java tools?

  • Making executable jar file the database using JTable

    How can i make an executable jar file if I will use a JTable on my database?Can you tell me how?
    Thank you !!

    dantte wrote:
    in truth, ur question is not clear enough. elaborate on what exactly it is u want, and what u ar truin to achieve.You don't seem to know enough English, let along Java, to be answering questions here.
    %

  • JAR file and db connection

    I just discovered that you can run your application in Windows environment by double clicking the .jar file. You learn something new every day. Anyhoo, the problem is that I cannot connect to my db server. But when I run the application in NetBeans everything goes smoothly. What do I need to fix? Thanks........
    Z

    Never mind..........we just got it. All we did was
    copy the 3 jar files into jre\lib\ext\ folder and it
    worked. We don't know why but it worked. ThanksDouble clicking on the jar means that it is an executable jar.
    Executable jars do not use the normal class path. You normally jar up the additionally jars into the jar itself. Then you add a entry to the manifest file that 'sets' the classpath to them (in the jar.) You would have to search the forums for that exact line.
    The 'ext' directory is used by the JVM as an addition to the class path. Basically the JVM class path is normally constructed with the following.
    - Various bootpath options (see the java docs for more on this.)
    - The env var or the classpath command line option.
    - The java api
    - The jars or exploded trees in the ext directory.
    Some people would suggest that you not use the ext dir as you are doing. Their contention is that it is intended basically for the VM use only (for 'standard' additions.) Another downside is that every VM application is now accessing those jars and that will make using different versions of a jar impossible. And you might forget that the jars are there and thus your delivered application won't work.

  • Creating an executable jar-file including a custom package

    I am trying to learn how to create executable jar-files. I have managed this with a single class. However having a class which is an extention of another class which in turn belongs to custom package, I can't make it work.Running the program normally is not a problem. I don't think the problem is the actual code, but I will include it here anyway. I create the jar-file using:
    jar -cmf Direkt2b.txt Direkt2b.jar *.class
    where Direkt2b.txt is just:
    Main-Class: Diriekt2b
    Only the main class-file is included this way. Copying the other file to the same directory before creation doesn't help either. There is no error messages, the jar-file just refuses to run no matter what.
    The main-class:
    import java.awt.*;
    import extra.*;
    class Direkt2b extends ExtendedFrame {
         Font f;
         Direkt2b() {
              f = new Font("SansSerif", Font.BOLD, 24);
              setBackground(Color.yellow);
              setSize(400,150);
         public void paint(Graphics g) {
              g.setFont(f);
              g.setColor(Color.blue);
              g.drawString("V?lkommen till Java Direkt", 45, 100);
         public static void main (String[] arg) {
              Direkt2b d2 = new Direkt2b();
              d2.setVisible(true);
    The help-class:
    package extra;
    import java.awt.*;
    import java.awt.event.*;
    public class ExtendedFrame extends Frame {
         private static boolean first = true;
         private boolean isFirst = first;
         public ExtendedFrame() {
              addWindowListener(theListener);
              first=false;
         WindowAdapter theListener = new WindowAdapter () {
              public void windowClosing(WindowEvent e) {
              dispose();
              if (isFirst)
                   System.exit(0);
    }

    My problem wasn't really getting more than one class in a jar-file,
    but rather that my jar-file with multiple classes wouldn't execute.
    Reading the original post I realized that maybe I was unclear about that.
    However I have solved the problem now so for anybody reading this
    thread in the future I will tell you how.
    The general setting is this: You have a bunch of self-made help-classes
    organized in some classdirectory somewhere in the filesystem. You use these
    in your programming from time to time. You have set a classpath-varible
    in your OS such that Java could find your help-classes.
    Now you want to create executable jar-files so that you could publish your work.
    My problem was that while I added all needed classes in a jar-file, the main-class
    couldn't find the others because they were referenced incorrectly. The solution I
    came up with may not be elegant, but it works. I copied the main-class and all directories
    (only one in my case) just as they appear in the classpath-directory, to the same temporary
    directory. Then I created the jar-file from there, using: jar -cmfv Direkt2b.txt Direkt2b.jar Direkt2b.class extra/*.class
    I suspected that incorrect referencing was the problem and I tried several variations on the theme above
    before giving up and writing the first post. Part the problem was that I didn't get any error messages,
    just an annoying error-sound double-clicking the jar-file. I learned later that you could run jar-files from
    the command -prompt using: java -jar myjarfile.jar. This way you get a more useful response.
    I guess there is a way to include the classpath instead somehow, but I will use my method for now.
    I hope this was helpful to somebody.

  • Using Third-Party jar file in database; Where to put license file?

    Hi!
    I have a third-party product that has a .jar file that references some .so files. I have successfully loaded the .jar file and the .so files are being called successfully, but when the program gets to the part where it reads the third-party license file, it is failing (ORA-3113 and an hs_err_pid<12345>.log and udump file are created. I know the issue is the location of the license file because I am getting the same exact error when I run it outside of the database. (I have been able to run it successfully outside of the database.)
    The instructions for the third-party product say to put the license file in the application's runtime directory.
    What I can't figure out is this: What is the application's runtime directory when I am running the code in the database?
    I thought it would be user.dir which is set to $ORACLE_HOME, but putting the license file there didn't work. I have tried lots of other places under $ORACLE_HOME.
    Any ideas?
    Thanks,
    Laurel

    Hi Laurel:
    Whether or not you can read the license file, sure you will have problem then when trying to load your .so file.
    Java JNI call are not allowed inside OJVM for security reasons, see Kuassi's answer to a similar question:
    Access Berkeley DB from Java Stored Procedure
    Best regards, Marcelo.

  • How to include a JSP page contained in a JAR file ?

    Hello,
    I have a Servlet in which I would like to include, in the Response, the content of a JSP page contained in an external JAR file included in my lib directory ?
    Could someone help me please ?
    Thanks in advance.
    bgOnline

    I don't think thats possible with the standard j2ee server.
    There are probably ways around it, but it would involve a large component of custom coding.

Maybe you are looking for

  • Authorization issue in HR: Manager has access to other employees

    Hello Gurus, I need to restrict access to HR reports to Users based on their group segment. Situation I am facing is that a level 1 user(Segment manager) belonging to a particular Group segment is getting access to data of employees other than those

  • APPLE'S GOT SOME EXPLAINING TO DO!

    Everytime I connect my ipod to my computer it takes like 5 mins to do anything and my computer freezes. Then the do not disconnect display comes on and when i try and safely remove it, it says its used by another program?? EXPERIENCED PEOPLE PLEASE H

  • !Important! Custom InfoObject - Unit Of Measure

    Hi Experts, i have a quite complex requirement. we have an infoobject that has Unit Of measure or in other words something like product group. the problem is that when we do reporting. the key figures are cumulated per UOM "PC". we want a to cummulat

  • Change PGA for session?

    Hi there, we are developing an OLTP application on 11gR2. As a consequence of having a lot of small transactions, we have configured a relatively small PGA and a lot of SGA memory and have configured the optimizer relevant parameters for choosing b-t

  • Captions

    Is there a file where captions are stored? I would like to be able to either move them via copy/paste or at least print them out. Reason: I am converting old slide carousels and editing in Elements before putting them in a slide show. While scanning