Original Post
🔒 Locked
[java] Eclipse newbie question
Advertisement
Eclipse's package explorer probably has some sort of filter for .java files, which kinda makes sense, because packages only contain .java source files. When you build all your packages then they become .class files.
Do you care to explain why you want to use .class files? Java libraries work through .jar files which you can then add to your project and use as you like.
Do you care to explain why you want to use .class files? Java libraries work through .jar files which you can then add to your project and use as you like.
If possible, use external libraries in .jar form. But if you can't do that, IIRC you should be able to do it like this:
- right click the project
- select 'properties'
- click the 'libraries' tab
- click 'add class folder' and point it at a directory containing the .class files. Remember you still have to use the package directory structure in there too.
- right click the project
- select 'properties'
- click the 'libraries' tab
- click 'add class folder' and point it at a directory containing the .class files. Remember you still have to use the package directory structure in there too.
Better to get into the habit of using jar files. To create your jar file do the following:
This will place all of the files (indicated by the wildcard *) underneath the current directory into your jar file and name if MyJarName.jar. You'll need to do this at the top of your package structure.
Free Tip 1: When you want to see whats inside a jar file unzip it with the following command:
Although you can navigate through the contents of a jar file inside of Eclipse, which is probably quicker.
Free Tip 2: Create a "lib" subdirectory in your Eclipse project and place any .jar files you use in there. Don't forget to add your jar to your build path by doing Project->Properties->Libraries->Add JARs.
Jon
Quote:
$jar -cvf MyJarName.jar *
This will place all of the files (indicated by the wildcard *) underneath the current directory into your jar file and name if MyJarName.jar. You'll need to do this at the top of your package structure.
Free Tip 1: When you want to see whats inside a jar file unzip it with the following command:
Quote:
$jar -xvf MyJarName.jar
Although you can navigate through the contents of a jar file inside of Eclipse, which is probably quicker.
Free Tip 2: Create a "lib" subdirectory in your Eclipse project and place any .jar files you use in there. Don't forget to add your jar to your build path by doing Project->Properties->Libraries->Add JARs.
Jon
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement