Adding a .class file to your Java project.
All I can say is Java class paths are a real pain in the butt. Recently I developed a Java Swing application using the JTwain library. The company I purchased the library from uses a .class file as their license. The only instructions were to put this file in your class path. It sounded simple enough but this was the first time I have ran across this and was unsure the correct way to get the class file in my project. After several failed attempts and many trips to “The Googles” I came up with the following solution. It is pretty simple and works great. I am using Netbeans IDE but the same concepts should be the same for Eclipse, JDeveloper, etc…
- Create a new project. In Netbeans you want to create a Java Class Library project.
- Next you want to copy your .class file into the src directory of your project.
- Once you have the .class files in your src directory you can right click on your project select Clean and Build.
- After you build the project you should see the jar file in your projects dist directory. You can simply add this jar file to your project just like any other jar file and it will automatically be in the class path.