File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Importing packages from a .jar

 
George C Nixon
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm having a lot of difficulty doing something fairly simple... I just want to import a package in one .java file from a .jar file that's in the same directory, but javac is giving me headaches. I can't find the right command in Windows command prompt to make this compile. I keep trying stuff like:

javac NameUser.java -classpath=.;Name.jar

And more complicated variants with full path names. No joy!

I'm sure this'll be an easy one, so thanks in advance

George
 
Steve Luke
Bartender
Pie
Posts: 4181
21
IntelliJ IDE Java Python
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't done things from the command line in a while, so I could be off, but I think you need to put the name of the .java file at the end of the command, and the options you want to use before it:

javac -classpath=.;Name.jar NameUser.java

You might also benefit from surrounding the classpath in quotes, not sure though

javac -classpath=".;Name.jar" NameUser.java
 
George C Nixon
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for replying, Steve

I just tried this line (cut and pasted from my command line):

javac -classpath=".;Name.jar" NameUser.java

But I still get the messages:
javac: invalid flag: -classpath=.;Name.jar
Usage: javac <options> <source files>
use -help for a list of possible options

Any ideas?? G
 
Steve Luke
Bartender
Pie
Posts: 4181
21
IntelliJ IDE Java Python
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, just ran it myself, get rid of the equal sign:

 
George C Nixon
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Urgh, thanks! You stare at code long enough, and you stop seeing things like that!

I've got an error trying to run the program, but at least it seems to have compiled.

Thanks Steve! G
 
Steve Luke
Bartender
Pie
Posts: 4181
21
IntelliJ IDE Java Python
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your quite welcome. These are easy mistakes to make, so don't feel bad at all. Just keep chugging :-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic