Update: Apparently I had a serious concussion when I wrote this, as I completely overlooked the obvious. "Hello, McFly - svn? I hear Google code has it too." So do not bother using these instructions. It is much simpler pull the project from SVN.
When I researched the
JavaSE component of ZXing, I compiled the jars I needed with Eclipse 3.4.1 . The set up was relatively simple. But there were several steps needed to get everything up and running properly. So I decided to write up a quick set of instructions.
Note: ZXing contains several components (javase, javame, servlet, android, etcetera). These instructions only cover the JavaSE component. You may notice I imported the full source. But to actually use the other components in the project, additional files are needed. For further instructions see the project's Getting Started section
Instructions
1. Download the latest source and extract the files.
As of this entry, the current version is ZXing-1.4.zip. (Your version may differ.)
2. Create a new project in Eclipse.
- Use whatever you project name you wish. Example: "ZXing"
- Make sure the project JVM is 1.5 or higher
3. Import the source files into the project
- Select File => Import => File System => Next
- Supply the source and destination
1. Navigate to the extracted files and select the ZXing-1.4 subfolder . 2. In the main window, check the ZXing-1.4 folder, so its contents are imported 3. Select the top level folder of your project (not "src") for Into Folder
- Make sure Create selected folders only is selected
- Finally, click Finish to import the files into the project
4. Next Configure the Build Path
After the source files are imported, you need to configure the project build path. Each sub-component in ZXing has its own separate src folder. Each of them must be added to the build path. ZXing also has a few jar dependencies. Those jars must be added to the project build path as well.
You could modify the path using Eclipse's "Configure Build Path" option. But a shortcut
is to modify the project's .classpath file manually.
- Find and open the project's .classpath file
- Paste in the new class path entries below and save the file.
- Close and re-open the project in Eclipse to apply the changes.
New Class Path Entries
<classpathentry kind="src" path="android/src"/>
<classpathentry kind="src" path="bug/src"/>
<classpathentry kind="src" path="core/src"/>
<classpathentry kind="src" path="core/test/src"/>
<classpathentry kind="src" path="javame/src"/>
<classpathentry kind="src" path="javase/src"/>
<classpathentry kind="src" path="rim/src"/>
<classpathentry kind="src" path="zxingorg/src"/>
<classpathentry kind="lib" path="bug/lib/osgi.jar"/>
<classpathentry kind="lib" path="core/lib/junit.jar"/>
<classpathentry kind="lib" path="zxingorg/web/BarcodeReader.jar"/>
<classpathentry kind="lib" path="zxingorg/web/basic/BarcodeReader.jar"/>
<classpathentry kind="lib" path="zxingorg/web/WEB-INF/lib/commons-codec-1.3.jar"/>
<classpathentry kind="lib" path="zxingorg/web/WEB-INF/lib/commons-fileupload-1.2.1.jar"/>
<classpathentry kind="lib" path="zxingorg/web/WEB-INF/lib/commons-io-1.4.jar"/>
<classpathentry kind="lib" path="zxingorg/web/WEB-INF/lib/commons-lang-2.4.jar"/>
<classpathentry kind="lib" path="zxingorg/web/WEB-INF/lib/commons-logging-api-1.1.1.jar"/>
<classpathentry kind="lib" path="zxingorg/web/WEB-INF/lib/httpclient-4.0.jar"/>
<classpathentry kind="lib" path="zxingorg/web/WEB-INF/lib/httpcore-4.0.1.jar"/>
<classpathentry kind="lib" path="zxingorg/web/WEB-INF/lib/httpcore-nio-4.0.1.jar"/>
<classpathentry kind="lib" path="zxingorg/web/WEB-INF/lib/httpmime-4.0.jar"/>
<classpathentry kind="lib" path="zxingorg/web/WEB-INF/lib/mailapi.jar"/>
<classpathentry kind="lib" path="zxingorg/web/WEB-INF/lib/pop3.jar"/>
<classpathentry kind="lib" path="zxingorg/web/WEB-INF/lib/smtp.jar"/>
.ClassPath File
.ClassPath File Contents
You should now be able to run both the core an javase components of the project from Eclipse
Building Jars
The project includes several ant build files to simplify the process of building jars. Again, each component subfolder contains its own separate build file. So you can easily build jars individually. Simply locate the build.xml file for the desired component. Then run the build task to generate the jar.
Example: To build the JavaSE Jar
- Locate the javase/build.xml file
- Run the build task in ant
- Ant will generate a javase.jar file inside the javase/ folder
...Read More