Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Compiling  RSS feed

 
Richard West
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I really deserve a kick for asking this question so please bear with me.

Assume i have two classes class a and class b.
Now class b depends on class a to compile correctly. Class a has been compiled and the class file is generated correctly. Now when i compile class b, it says it can't find class a although class a is in the same directory as the source of class b.

This is what in class a



This is what is class b



Please note that both the sources of class a and class b are in the same directory and there are no packages involved.

Now this is how i am compiling class b



Is there any classpath setting that i need to take care of so that my class b can compile.

Again i apologize for my stupidy

Yours Sincerely

Richard West
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you have the CLASSPATH environment variable set, and it doesn't include "." (dot), the current directory. You could change CLASSPATH, or better yet, undefine it altogether, because using a global CLASSPATH causes all sorts of little issues like this.

Or you could just say

javac -classpath . b.java

Or even

javac a.java b.java
 
Richard West
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I tried inputting these values into a string array and used the runtime class to compile my class. This is what the string array looks like



I still get the error that it can't find class a although its clearly there

Richard West
 
Richard West
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

Is there anyone that knows this??

Richard West
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are javac and b.java not inside double quotes? Have you defined a variable named javac? What's going on?
 
Richard West
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jim Yingst:
Why are javac and b.java not inside double quotes


They are string objects. javac is location of javac.exe on my computer and b.java is the location of my b.java class

Its getting rather strange for me. I know b.java depends on class a to compile correctly but class a has already been compiled and its there in the same directory as the source file of b.java.

Its strange why this happening. You see both a.java and
b.java are in separate source files and are both public classes. The thing
is that if both the classes are in the same source file i will not have
any problems compiling.

I am not doing anything special except calling a class that
has already been compiled.

I have never ever run into this problem and would really
appreciate any further input on this topic.

Yours Sincerely

Richard West
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!