2

I have a REALLY simple app, that helps in repetitive tasks concerning script executions. No problem with that. App works perfectly in eclipse.

I use ojdbc14.jar to work with my Oracle DB.

Now, I wanted to create an exe file in order to distribute this little app amongst team mates, but the problem is, that when I run my app from .exe, there seems to be no connection with DB at all.

I am using maven and launch4j in order to pack my app into an exe, and maven-shade-plugin.

Here is my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>miniApp</groupId>
  <artifactId>miniApp</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <dependencies>
      <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc</artifactId>
        <version>14</version>
        <scope>system</scope>
        <systemPath>${project.basedir}/lib/ojdbc14.jar</systemPath>
      </dependency>
  </dependencies>

  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
       <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>1.7.1</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <shadedArtifactAttached>true</shadedArtifactAttached>
                <shadedClassifierName>shaded</shadedClassifierName>
                <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                        <mainClass>miniApp.App</mainClass>
                    </transformer>
                </transformers>
            </configuration>
        </plugin>
        <plugin>
            <groupId>com.akathist.maven.plugins.launch4j</groupId>
            <artifactId>launch4j-maven-plugin</artifactId>
            <version>1.5.1</version>
            <executions>
                <execution>
                    <id>l4j-clui</id>
                    <phase>package</phase>
                    <goals>
                        <goal>launch4j</goal>
                    </goals>
                    <configuration>
                        <headerType>gui</headerType>
                        <jar>${project.build.directory}/${project.artifactId}-${project.version}-shaded.jar</jar>
                        <outfile>${project.build.directory}/miniApp.exe</outfile>
                        <downloadUrl>http://java.com/download</downloadUrl>
                        <classPath>
                            <mainClass>miniApp.App</mainClass>
                            <preCp>anything</preCp>
                        </classPath>
                        <icon>src/Settings.ico</icon>
                        <jre>
                            <minVersion>1.6.0</minVersion>
                            <jdkPreference>preferJre</jdkPreference>
                        </jre>
                        <versionInfo>
                            <fileVersion>1.0.0.0</fileVersion>
                            <txtFileVersion>${project.version}</txtFileVersion>
                            <fileDescription>${project.name}</fileDescription>
 [![enter image description here][1]][1]                           <copyright>2012 hasCode.com</copyright>
                            <productVersion>1.0.0.0</productVersion>
                            <txtProductVersion>1.0.0.0</txtProductVersion>
                            <productName>${project.name}</productName>
                            <companyName>miniApp.com</companyName>
                            <internalName>miniApp</internalName>
                            <originalFilename>miniApp.exe</originalFilename>
                        </versionInfo>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
  </build>
</project> 

Here is my MANIFEST.MF

Manifest-Version: 1.0
Specification-Title:    Oracle JDBC driver classes for use with JDK14
Sealed: true
Created-By: 1.4.2_14 (Sun Microsystems Inc.)
Implementation-Title:   ojdbc14.jar
Specification-Vendor:   Oracle Corporation
Specification-Version:  Oracle JDBC Driver version - "10.2.0.4.0"
Implementation-Version: Oracle JDBC Driver version - "10.2.0.4.0"
Implementation-Vendor:  Oracle Corporation
Implementation-Time:    Sat Feb  2 11:40:29 2008

Name: oracle/sql/converter/
Sealed: false

Name: oracle/sql/
Sealed: false

Name: oracle/sql/converter_xcharset/
Sealed: false

And here is my really simple project structure:

prjct

Searched the internet to see if I could get some answers, but questions from people getting the same problems weren't answered.

Any ideas on why this might not be working?

If my question isn't clear or I'm missing any details, please let me know how I can improve my question.

Thanks in advance.

Manuel S.
  • 411
  • 8
  • 21

1 Answers1

0

Few Comments and answers: (1) ojdbc14.jar is very old. What is the version of your Oracle database? Can you use the latest JDBC drivers? ojdbc7.jar from 12.1.0.2 or 12.1.0.1 ?

(2) Oracle JDBC drivers are not present in the public maven repository. So, you will need to download JDBC drivers manually from OTN page

Guide to installing 3rd party Jars" for more information.

mvn install:install-file \ -Dfile=/lib/ojdbc7.jar \ -DgroupId=com.oracle \ -DartifactId=ojdbc7 \ -Dversion=12.1.0.1 \ -Dpackaging=jar \ -DgeneratePom=true

Nirmala
  • 1,278
  • 1
  • 10
  • 11
  • Hi @Nirmala, thanks for your answer. I'm using ojdbc14 because we are working on an Oracle 10g DB. I've already downloaded ojdbc driver manually, as u can see in my pom, repo links to a local file: ${project.basedir}/lib/ojdbc14.jar. There's nos problem with the driver. App is working perfectly when I run it from eclipse. The problem is, the driver is not being packed into the .exe. So when I run my app from the exe, it can't find the driver. – Manuel S. Feb 05 '16 at 07:47