• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't find .class file

 
Darryl Failla
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Darryl Failla
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic