• Post Reply Bookmark Topic Watch Topic
  • New Topic

Howto use wildcard java class  RSS feed

 
Mona Mayer
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, my name is Mona and I am a greenhorn

I am trying to write my first java program and got stuck.

I want to search for files using wildcards. After a lot of googling I found https://github.com/EsotericSoftware/wildcard. I downloaded the .java files and put them in the same directory as my own java file. but now I don't know, how to include this java file.


Can somene give me a hint?
 
Stevens Miller
Bartender
Posts: 1445
30
C++ Java Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Mona. That looks like an ambitious choice for a first program, even if you are skilled in another language. Before jumping into something like that, you might be better off trying something much simpler.

To help you, we will probably need to know a bit about your situation. Have you written programs in other languages? Are you using Eclipse, NetBeans, or some other IDE? Have you got some code already written that you can show us? (If you do, please post it and UseCodeTags when you do.)

Lots of helpful people here will usually lend a hand, once we have more to go on.
 
Mona Mayer
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I started pretty simple:

My java file (search.java):


I copied the file Paths.java into the same directory. But when I try to comile (with JCreator) I get the error:

"
--------------------Configuration: <Default>--------------------
D:\datastore\java\search.java:5: error: cannot access Paths
Paths paths = new Paths();
^
bad source file: D:\datastore\java\Paths.java
file does not contain class Paths
Please remove or make sure it appears in the correct subdirectory of the sourcepath.
1 error

Process completed.


If I get the message right, JCreator complains there is no class "Paths" in the file Paths.java?

But when I open the file Paths.java there is a class called "Paths":

Paths.java:
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are not using packages, then delete the package statement from the very first line of Paths.java:

package com.esotericsoftware.wildcard;
 
Mona Mayer
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That worked, thanks!

May I ask (for learing purposes ) what I did wrong, using packages? I tried


but got the same error message
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mona Mayer wrote:May I ask (for learing purposes ) what I did wrong, using packages?

It would be a bit long to answer here, so I'lll direct you to the Oracle tutorial lesson on the subject.
 
Mona Mayer
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. I followed your advice an read the tutorial (twice).

My Java file is in the directory D:\datastore\java

I copied the files

Paths.Java
GlobScanner.java
RegexScanner.java

(all of them contain the first row: "package com.esotericsoftware.wildcard)

to the subdirectory

D:\Datastore\java\com\esotericsoftware\wildcard

in my javafile I added the line
"import com.esotericsoftware.wildcard;"

but still Jcreator complains:

D:\datastore\java\search.java:1: error: package com.esotericsoftware does not exist
import com.esotericsoftware.wildcard;
^
D:\datastore\java\search.java:7: error: cannot find symbol
Paths paths = new Paths();

 
Mona Mayer
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it. The "*" is missing at the end:

import com.esotericsoftware.wildcard*;

Thanks for the help!!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!