Setting the classpath for JAR files

后端 未结 2 1684
予麋鹿
予麋鹿 2021-01-12 17:44

I have recently just created Java project using Eclipse that requires 2 JAR files (phiget21.jar and the mysql.jar)

Everything works fine when running the programme i

相关标签:
2条回答
  • 2021-01-12 18:21

    You need something like

    java -classpath lib/foo.jar:. com.company.Program
    

    you can also use wildcards since java 6. see here

    so the above becomes

    java -classpath lib/*:. com.company.Program
    
    0 讨论(0)
  • 2021-01-12 18:25

    while setting the classpath a single dot (.) means current directory. As you jar files are in current directory, you just need to go to your current directory using cd command in DOS prompt, then use

    set classpath = .;filename.jar;another filename.jar
    

    Here . represents current directory and semicolon separates each classpaths.

    You can even set classpath of more than one jar files using wild card character * which can be read as all.

    0 讨论(0)
提交回复
热议问题