• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with Package execution  RSS feed

 
Vinay Kumar chowdary
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I am facing some problem regarding compilation of a class in a package.

I am trying to compile the below test.java file by using the command

javac -d classes src\com\example\web\test.java

but its not recognising Hello.java even though its compiled.
Please help me out as i got stuck up here.I attached the 2 files below


/**************test.java********************/
package com.example.web;
import com.example.model.Hello;

public class Test

{

public static void main(String args[])
{
Hello t=new Hello();

t.calledMethod();

}
}


/***********Hello.java***********************/



package com.example.model;


public class Hello

{


public void calledMethod()
{
System.out.println("Hi im in the Called method");

}


}
 
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
Hi,

Welcome to JavaRanch!

To help you, I'd have to know what "It is not recognizing Hello.java" means. "It" is the compiler, or the JVM itself? What did you type, and what was the error message you received?
 
Vinay Kumar chowdary
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The directory structure of my project is
c:\project\helloTest\src\com\example\

Hello.java is placed in c:\project\helloTest\src\com\example\model

test.java is placed in c:\project\helloTest\src\com\example\web

I am trying to place the generated class files in
c:\project\helloTest\classes\com\example\

I am executing the following command to compile the file test.java

C:\project\helloTestTest>javac -d classes src\com\example\web\test.java


but is giving error as below

package com.example.model does not exist


Please help
 
Praveen Balaji
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are basically trying to figure out how to use javac to compile multiple files. Please refer to javac: Java Programming Language Compiler

What you need is:

javac -d classes com/example/model/Hello.java com/example/web/test.java
 
Vinay Kumar chowdary
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Thanks for your solution...

The problem is resolved now...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!