aspose file tools
The moose likes Java in General and the fly likes Compile error saying I need to recompile servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Compile error saying I need to recompile servlet" Watch "Compile error saying I need to recompile servlet" New topic
Author

Compile error saying I need to recompile servlet

Ed Gretson
Greenhorn

Joined: Jul 26, 2006
Posts: 4
I am trying to get my java class to compile.

My first one (the bean) compiles but the second one that calls the bean class doesnt compile:

bean class file that compiles and works:



The CustomerManager Servlet that wont compile:



Here is my error message:

C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\test\WEB-INF\clas
ses>javac beans\CustomerManager.java
Note: beans\CustomerManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.


Please advise.

[ July 26, 2006: Message edited by: Ed Gretson ]
[ July 26, 2006: Message edited by: Ed Gretson ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56208
    
  13

It's compiling, that's just a warning.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56208
    
  13

As this is not servlet-specific and an issue with the use of JDK 1.5 generics, this has been moved to the Java in General (intermediate) forum.
Ed Gretson
Greenhorn

Joined: Jul 26, 2006
Posts: 4
Thanks for your quick response.

If possible can you advise what "unchecked or unsafe operations" that are located in the CustomerManager class?
Christian Spreiter
Greenhorn

Joined: Nov 07, 2005
Posts: 5
as already mentioned, it's just a warning. the reason is your ArrayList and to be precise this line

rv.add(getCustomer(String.valueOf(i)));

you can add any type into this ArrayList. In your case you only want String objects in your ArrayList. Generics (as of java 1.5) solve this problem and would eliminate the warning

so instead of

List rv = new ArrayList();

use
List<String> rv = new ArrayList<String>();

this makes sure that you only add String objects to the ArrayList


hope this helps chris
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24057
    
  13

Originally posted by Ed Gretson:

If possible can you advise what "unchecked or unsafe operations" that are located in the CustomerManager class?


Java 5 introduced the concept of "Generics," which add "type safety" to the Collections API, among other things. The warning means, simply and completely, that you're not using this new feature.

For more info, see here.


[Jess in Action][AskingGoodQuestions]
Ed Gretson
Greenhorn

Joined: Jul 26, 2006
Posts: 4
thanks!
Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12929
    
    3

Please notice the warning message that you get:

Note: beans\CustomerManager.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.


Especially look at the second line. It tells you that if you want to know the details, compile your source code with the command line option -Xlint:unchecked. So, just do exactly what it says, compile your code like this:

javac -Xlint:unchecked beans\CustomerManager.java


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Compile error saying I need to recompile servlet
 
Similar Threads
JPA-Hibernate One-to-One Bidirectional Relationship issue
not getting what this servlet is doing+MVC
[AspectJ] Adding PropertyChangeEvents
Simple Person Program
problem in accessing a list through a iterate tag.