Search code examples
javajarclasspathconio

Java using classes from jar


This must be a super overasked question. Although here goes:

I have a java file for testing around (hworld.java) and am trying to import conio.jar, a JAR which is a wrapper of Conio. The JAR contains only one class file (conio.class) and META-INF. Trying to do import conio.* or import conio.conio shows me this:

C:\Documents and Settings\Nick\Desktop>javac -cp *.jar; hworld.java
hworld.java:3: error: package conio does not exist
import conio.*;
^
1 error

And compiling it like javac -cp conio.jar hworld.java still errors out while compiling. I even extracted the jar and had conio.class in the same directory as hworld.java but to no avail. The JAR is in the same directory as hworld.java, as well.

Anyone have any idea on how to fix this?


Solution

  • You don't mention whether conio.class is defined in package conio. If it is not, then simply use the class without importing it. Remove the import.