• 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
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Compile error saying I need to recompile servlet

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Marshal
Posts: 67279
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's compiling, that's just a warning.
 
Bear Bibeault
Marshal
Posts: 67279
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your quick response.

If possible can you advise what "unchecked or unsafe operations" that are located in the CustomerManager class?
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Ed Gretson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks!
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
No matter. Try again. Fail again. Fail better. This time, do it with this tiny ad:
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!