Results 1 to 5 of 5
- 04-27-2012, 01:05 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 5
- Rep Power
- 0
Compiling a Class into a Package Problem -
hello -
i am attempting to compile a java class into a package from the command line.
- i am able to process javac ProblemServlet.java
- however when i attempt to javac -d ProblemServlet.java, receive the following error in the command line:
javac: invalid flag: files/apache
Usage: javac <options> <source files>
use -help for a list of possible options.
-------------------------------------------------
backstory - i've just moved an older application from a JRUN server to a TOMCAT 7 server running on Windows 7 Prof and need to change the database connnection string.
the servlets i'm am adjusting have been complied previously in the JRUN environment, so the file structure or the package details have not been altered. i am simply trying to adjust database connection strings.
surely i am missing something. but i am unclear as to why javac = fine, but javac -d = unable to compile.
any suggestions or ideas would be great.
thanks in advance.
best,
mb.
- 04-27-2012, 01:26 AM #2
Senior Member
- Join Date
- Apr 2012
- Location
- New York State of Confusion, USA
- Posts
- 137
- Blog Entries
- 1
- Rep Power
- 0
Re: Compiling a Class into a Package Problem -
According to "javac -help", the -d flag requires a directory. You gave it a file. Give it what it wants and I expect it will gladly give you what you want.
- 04-27-2012, 01:49 AM #3
Member
- Join Date
- Apr 2012
- Posts
- 5
- Rep Power
- 0
Re: Compiling a Class into a Package Problem -
thx jlczuk.
and i agree. the issue is when i use javac ProblemServlet.java -d PackageLevelA, then it complies the class into a package that looks like PackageLevelA > PackageLevelA > PackageLevelB>ProblemServlet. Class versus what i want of:
PackageLevelA > PackageLevelB > ProblemServlet.Class
Since I have to be in the class directory to compile ProblemServlet.java - I am unable to reach my desired goal.
Any insights ?
- 04-27-2012, 01:56 AM #4
Senior Member
- Join Date
- Apr 2012
- Location
- New York State of Confusion, USA
- Posts
- 137
- Blog Entries
- 1
- Rep Power
- 0
Re: Compiling a Class into a Package Problem -
I wish I could be of more help, but I work in Eclipse, so I don't use javac brute force from a command prompt. Generally, the source tree structure mirrors the package name. So if ProblemServlet is in package PackageLevelA.PackageLevelB the source file will be in PackageLevelA/PackageLevelB/ProblemServlet.java.
Have you tried running javac, without -d, from the parent directory of PackageLevelA? I would expect the .class file to be created in the same directory as the source.
- 04-27-2012, 03:49 PM #5
Member
- Join Date
- Apr 2012
- Posts
- 5
- Rep Power
- 0
Re: Compiling a Class into a Package Problem -
appreciate the help. actual solution turned out to be:
javac ProblemServlet.java -d .
this then allowed for the class to be compiled in the proper/necessary package while keeping all .java files in the web-inf/classes folder.
thanks again for your time.
best,
mb.
Similar Threads
-
CMD Package Compiling
By buston01 in forum Advanced JavaReplies: 2Last Post: 12-10-2010, 07:04 AM -
Facing problem in compiling user defined package
By UJJAL DHAR in forum New To JavaReplies: 2Last Post: 05-24-2010, 11:40 AM -
Package Compiling
By kaperks in forum Advanced JavaReplies: 1Last Post: 02-23-2009, 02:56 PM -
[SOLVED] Compiling Package Class
By nwboy74 in forum New To JavaReplies: 3Last Post: 11-14-2008, 11:19 PM -
Compiling a class in a package from cmd
By Java Tip in forum Java TipReplies: 0Last Post: 12-17-2007, 10:27 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks