aspose file tools*
The moose likes Servlets and the fly likes Can't find .class file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Can Watch "Can New topic
Author

Can't find .class file

Darryl Failla
Ranch Hand

Joined: Oct 16, 2001
Posts: 128
Using this:
SET JAVA_HOME=C:\jdk1.3.1
SET J2EE_HOME=C:\j2sdkee1.3
SET PATH=%PATH%;%JAVA_HOME%\bin;%J2EE_HOME%\bin
SET CLASSPATH=%JAVA_HOME%\lib\tools.jar;%J2EE_HOME%\lib\j2ee.jar;%J2EE_HOME%\lib\jhall.jar;.
I created a servlet and compiled using:
javac -classpath MyServlet.java
The compile gave no errors and appeared to compile properly; however I cannot find MyServlet.class anywhere. If I compile a non-J2EE class in the same directory, the .class file shows up as it should.


Darryl Failla
Sun Certified Java 2 Programmer
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

The -classpath option for the java compiler javac is used to specify external jar files for the compiler to look for. I don't know if this is causing your problem, but you can ommit the -classpath option. So just do:
javac myServlet.java


GenRocket - Experts at Building Test Data
Darryl Failla
Ranch Hand

Joined: Oct 16, 2001
Posts: 128
I found the problem. There was actually a syntax error in the code. The confusing part is that the compiler never alerted me. The command prompt went to the next line as though the compile were successful. Any ideas why that would happen?
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

javac is a bit glitchy when you type exactly what you typed. You provided the -classpath switch, but didn't give it a value. It quietly fails when you do this.

And Gregg: You should *absolutely* always use -classpath when compiling. There have been numerous discussions about this, most of them along the lines of "classpath, why do you hate me so?"

I highly recommend -classpath. It solves many problems. When people say "Just say no to CLASSPATH" they mean the system classpath setting.

By default though, include the dot directory.

javac -classpath . foo.java
Darryl Failla
Ranch Hand

Joined: Oct 16, 2001
Posts: 128
Thanks, I thought I was imagining things.
I have yet to find a clear explanation of what the dot at the end of the classpath is doing. Any directions?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't find .class file