• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

compilation problem

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i have really stupid problem with compilation.
my catalogs tree looks:
D:\javrob\Piwo-w1\classes\com\example\web
D:\javrob\Piwo-w1\classes\com\example\model
and src:
D:\javrob\Piwo-w1\src\com\example\web\WyborPiwa.java
D:\javrob\Piwo-w1\src\com\example\model\EkspertPiwny.java

the .java files looks:
//------------------------------------------
package com.example.model;

import java.util.*;

public class EkspertPiwny{
public List getMarki(String kolor){
List marki = new ArrayList<String>();
if(kolor.equals("bursztynowy")){
marki.add("Jack Amber");
marki.add("Red Moose");
} else{
marki.add("Jail Pale Ale");
marki.add("Gout Stout");
}
return (marki);
}
}
//---------------------------------------------
package com.example.web;

import com.example.model.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;

public class WyborPiwa extends HttpServlet {

public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {

response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Porada piwna<br>");
String c = request.getParameter("kolor");
out.println("<br>Wybrany kolor piwa:" + c);

EkspertPiwny be = new EkspertPiwny();
List wynik = be.getMarki(c);
Iterator it = wynik.iterator();
while(it.hasNext()){
out.println("<br>Sprobuj: "+ it.next());
}
}
}
//---------------------------------------------
first i compile ExpertPiwny.java:
D:\javrob\Piwo-w1>javac -classpath v:\tomcat\common\lib\servlet-api.jar -d classes src\com\example\model\EkspertPiwny.java
Note: src\com\example\model\EkspertPiwny.java uses unchecked or unsafe operation
s.
Note: Recompile with -Xlint:unchecked for details.

So i have new .class file in correct place D:\javrob\Piwo-w1\classes\com\example\model\ExpertPiwny.class

NEXT is a problem I WANT COMPILE second file but it doesn't work :
D:\javrob\Piwo-w1>javac -classpath v:\tomcat\common\lib\servlet-api.jar -d classes src\com\example\web\*.java
src\com\example\web\WyborPiwa.java:3: package com.example.model does not exist
import com.example.model.*;
^
src\com\example\web\WyborPiwa.java:21: cannot find symbol
symbol : class EkspertPiwny
location: class com.example.web.WyborPiwa
EkspertPiwny be = new EkspertPiwny();
^
src\com\example\web\WyborPiwa.java:21: cannot find symbol
symbol : class EkspertPiwny
location: class com.example.web.WyborPiwa
EkspertPiwny be = new EkspertPiwny();
^
3 errors

Why it doesn't import needed files if EkspertPiwny.class is in correct place?
WHERE IS WRONG? why it doesn't work
thanks for any help
 
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
javac cannot find the class EkspertPiwny because it's not in a jar or directory that is in the classpath.

You need to add the classes directory to the javac classpath.
[ November 03, 2006: Message edited by: Scott Johnson ]
 
Oczek Oczkowy
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok thanks for reply. but how to add it? Can you write compilation line?
thanks a lot
[ November 04, 2006: Message edited by: Oczek Oczkowy ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moved to Java In General (Beginner) where all javac and classpath issues are discussed.

You may also want to look at this page and the link it contains.
http://faq.javaranch.com/view?CompilingServlets
reply
    Bookmark Topic Watch Topic
  • New Topic