Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Mulitiple Files in -cp .. Need some help  RSS feed

 
Kari Smith
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I normally use the same -cp locations , but recently my code was modified, and now says it cannot find a file needed when I use javac command. I've done some internet research but can't seem get it.

My java file calls..

import java.io.*;
import java.sql.*;
import java.text.*;
import java.util.*;

import com.ctc.internal.util.DateFixer;
import com.ctc.util.csv.*;

Normally I try the following dos command..
>javac -cp .;ctc_util.jar;web-inf\lib\jt400.jar FileNametoExecute.java

Now I get the error that com.ctc.internal.util.DateFixer is not found. The DateFixer.java file is located at web-inf\classes\com\ctc\internal\util DateFixer.java


So I modified my command to read:
>javac -cp .;ctc_util.jar;web-inf\lib\jt400.jar;web-inf\classes\com\ctc\internal\util\DateFixer.java FileNametoExecute.java

I still get the same error. So I moved the DateFixer.java file into the web-inf\lib folder, and tried to access it there via the following two different commands to no avail.
>javac -cp .;ctc_util.jar;web-inf\lib\jt400.jar DateFixer.java FileNametoExecute.java
>javac -cp .;ctc_util.jar;web-inf\lib\jt400.jar;web-inf\lib\DateFixer.java FileNametoExecute.java

I even tried to build DateFixer.java (lol).. Grabbing at straws..

Can you please help me understand how to include multiple files in a class path for windows, and how the different file extensions matter when calling them?

Thank you.

 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your understanding of how classes are loaded is a bit flawed.

First of all, you don't need the .java files at all when running the application. When running it's the .class files you need. But don't throw away your .java files or you won't be able to recreate the .class files!
Second, the class path should contain the root of package structures, not the direct location of the classes.

You need to do two things:
1) Put the DateFixer.class file in folder web-inf\classes\com\ctc\internal\util.
2) Add web-inf\classes to your class path - without the com\ctc\internal\util part.
 
Kari Smith
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you this worked.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!