I'm trying to run a Java program that calls on the C:\Users\Brandon\Downloads\commons-io-2.4 folder. It compiled fine with this code javac -cp "C:\Users\Brandon\Downloads\commons-io-2.4\*" Login.java
but when I tried to run it with this code
java -cp C:\Users\Brandon\Downloads\commons-io-2.4\* Login
it gave me thiserror: Could not find or load main class Login.class
How do I fix this?
P.S. The program calls on the FileUtils.
Asked
Active
Viewed 35 times
0

brandon Whe
- 206
- 1
- 14
-
Is the class in a package? – TameHog Jul 21 '14 at 23:19
-
In the actual code I didn't state package I just said import org.apache.commons.io.fileutils – brandon Whe Jul 21 '14 at 23:31
-
I mean what package is `Login` in? – TameHog Jul 21 '14 at 23:41
-
It's just in c:users/Brandon/desktop/javacode – brandon Whe Jul 21 '14 at 23:42
-
Does the first line of `Login.java` say `package *.*.*;` – TameHog Jul 21 '14 at 23:43
-
No It doesn't it's the normal public class login then the void main string args – brandon Whe Jul 21 '14 at 23:45
2 Answers
0
Try this: java -cp C:\Users\Brandon\Downloads\commons-io-2.4\*;. Login
You have to add the current directory to the class path
If that doesn't work try java -cp C:\Users\Brandon\Downloads\commons-io-2.4\* -cp . Login

TameHog
- 950
- 11
- 23
-
These didn't work but thanks for the input and being patient for a beginner like me. I'm only 15 so I'm just getting started – brandon Whe Jul 21 '14 at 23:58
-
0
You need to add the current location as part of classpath.
java -cp .;C:\Users\Brandon\Downloads\commons-io-2.4\* Login
symbol .(dot) is the current path, separated by comma

sendon1982
- 9,982
- 61
- 44