How to create my own java library(API)?

Create a JAR. Then include the JAR. Any classes in that JAR will be available. Just make sure you protect your code if you are giving out an API. Don’t expose any methods / properties to the end user that shouldn’t be used. Edit: In response to your comment, make sure you don’t include the … Read more

Difference between java class and jar

A Jar file is an Zip archive containing one or multilple java class files. This makes the usage of libraries (consisting of multiple classes) more handy. Directories and Jar files are added to the classpath and available to the ClassLoader at runtime to find particular classes inside of it.

What is the best way to avoid maven-jar?

In Maven 3.0.x (I tried 3.0.2) you can disable maven-jar-plugin by binding the default-jar execution to a nonexistent phase, as @bmargulies suggested. Unfortunately that doesn’t work in 2.2.1, but you can prevent it from interfering with your own jar by setting an alternative <finalName> and <classifier> for the default-jar execution; it will still create a … Read more

How do you extract a JAR in a UNIX filesystem with a single command and specify its target directory using the JAR command?

If your jar file already has an absolute pathname as shown, it is particularly easy: cd /where/you/want/it; jar xf /path/to/jarfile.jar That is, you have the shell executed by Python change directory for you and then run the extraction. If your jar file does not already have an absolute pathname, then you have to convert the … Read more

How to create jar file with package structure?

You need to start creating the JAR at the root of the files. So, for instance: jar cvf program.jar -C path/to/classes . That assumes that path/to/classes contains the com directory. FYI, these days it is relatively uncommon for most people to use the jar command directly, as they will use a build tool such as … Read more

How to place the output jar into another folder with maven?

You can use the outputDirectory parameter of the maven-jar-plugin for this purpose: <project> … <build> <plugins> … <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.3.1</version> <configuration> <outputDirectory>../libs</outputDirectory> </configuration> </plugin> … </plugins> </build> … </project> But as cdegroot wrote, you should probably better not fight the maven way.

Reference jars inside a jar

You will need a custom class loader for this, have a look at One Jar. One-JAR lets you package a Java application together with its dependency Jars into a single executable Jar file. It has an ant task which can simplify the building of it as well. REFERENCE (from background) Most developers reasonably assume that … Read more

Where can I download mysql jdbc jar from? [closed]

Go to http://dev.mysql.com/downloads/connector/j and with in the dropdown select “Platform Independent” then it will show you the options to download tar.gz file or zip file. Download zip file and extract it, with in that you will find mysql-connector-XXX.jar file If you are using maven then you can add the dependency from the link http://mvnrepository.com/artifact/mysql/mysql-connector-java Select … Read more

How to use JarOutputStream to create a JAR file?

It turns out that JarOutputStream has three undocumented quirks: Directory names must end with a “https://stackoverflow.com/” slash. Paths must use “https://stackoverflow.com/” slashes, not ‘\’ Entries may not begin with a “https://stackoverflow.com/” slash. Here is the correct way to create a Jar file: public void run() throws IOException { Manifest manifest = new Manifest(); manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, “1.0”); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)