• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Problem with Package execution

 
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");

}


}
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • 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
 
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!