JuliaInterop / JavaCall.jl

Call Java from Julia
http://juliainterop.github.io/JavaCall.jl
Other
118 stars 53 forks source link

Is 'pattern == "*.jar"' in jvm.jl a bug? #154

Closed pzhanggit closed 2 years ago

pzhanggit commented 2 years ago

Hi, is this line https://github.com/JuliaInterop/JavaCall.jl/blob/4846e4e3d999dfd49fcca09a2a16fa658023f3ae/src/jvm.jl#L160 in function addClassPath(s::String) supposed to find jar files? If so, it seems to be a bug and should be something like if endswith(pattern, ".jar") && isdir(dirname)? Thanks.

mkitti commented 2 years ago

Notice the previous line: https://github.com/JuliaInterop/JavaCall.jl/blob/4846e4e3d999dfd49fcca09a2a16fa658023f3ae/src/jvm.jl#L158-L166

You cannot just say *.jar because this interpretation may be dependent on your current working directory. If you instead did JavaCall.addClassPath(joinpath(pwd(),"*.jar")) perhaps this might work for you?

mkitti commented 2 years ago
julia> using JavaCall

julia> cd(raw"C:\Users\kittisopikulm\Documents\fiji-win64\Fiji.app")

julia> readdir()
18-element Vector{String}:
 ".checksums"
 "Contents"
 "ImageJ-win64.exe"
 "README.md"
 "WELCOME.md"
 "db.xml.gz"
 "hs_err_pid27188.log"
 "hs_err_pid30104.log"
 "images"
 "jars"
 "java"
 "lib"
 "licenses"
 "luts"
 "macros"
 "plugins"
 "retro"
 "scripts"

julia> readdir("jars")
380-element Vector{String}:
 "FastInfoset-1.2.16.jar"
 "FilamentDetector-1.0.0.jar"
 "JWlz-1.4.0.jar"
 "Kappa-2.0.0.jar"
 "OMEVisual-2.0.0.jar"
 "ST4-4.0.8.jar"
 "T2-NIT-1.1.3.jar"
 "T2-TreelineGraph-1.1.3.jar"
 "VIB-lib-2.2.0.jar"
 "VectorGraphics2D-0.13.jar"
 "VectorString-2.0.2.jar"
 ⋮
 "win64"
 "xalan-2.7.2.jar"
 "xchart-3.5.4.jar"
 "xerbla-0.8.jar"
 "xercesImpl-2.8.1.jar"
 "xml-apis-ext-1.3.04.jar"
 "xmlgraphics-commons-2.4.jar"
 "xmpcore-5.1.3.jar"
 "xpp3-1.1.4c.jar"
 "xz-1.8.jar"
 "yecht-0.0.0-STUB.jar"

julia> JavaCall.addClassPath(raw"jars\*.jar")

julia> JavaCall.getClassPath()
"jars\\FastInfoset-1.2.16.jar;jars\\FilamentDetector-1.0.0.jar;jars\\JWlz-1.4.0.jar;jars\\Kappa-2.0.0.jar;jars\\OMEVisual-2.0.0.jar;jars\\ST4-4.0.8.jar;jars\\T2-NIT-1.1.3.jar;jars\\T2-TreelineGraph-1.1.3.jar;jars\\VIB-lib-2.2.0.jar;jars\\VectorGraphics2D-0.13.jar;jars\\VectorString-2.0.2.jar;jars\\ahocorasick-0.2.4.jar;jars\\alphanumeric-comparator-1.4.1.jar;jars\\annotations-13.0.jar;jars\\ant-1.9.7.jar;jars\\ant-launcher-1.9.7.jar;jars\\antlr-3.5.2.jar;jars\\antlr-runtime-3.5.2.jar;jars\\api-common-1.9.0.jar;jars\\args4j-2.0.25.jar;jars\\asm-7.1.jar;jars\\asm-analysis-7.1.jar;jars\\asm-commons-7.1.jar;jars\\asm-tree-7.1.jar;jars\\asm-util-7.1.jar;jars\\auto-value-annotations-1.7.jar
pzhanggit commented 2 years ago

Got you, thanks! @mkitti