This week's book giveaway is in the Other Open Source APIs forum. We're giving away four copies of Storm Applied and have Sean Allen, Peter Pathirana & Matthew Jankowski on-line! See this thread for details.
Folks, i've got a book on servlets, and thought that i'd try and run some of the examples in it. Things is, I can't compile even the most simple servlet. The problem lies in the use of the import statements, i'm sure of it. If I type in the following:-
I get an error saying: "Test.java": Error #: 901 : package com.omh stated in source E:\Java\Sams_Learn_Java\Test.java does not match directory . at line 1, column 13" What's going on?? All i did was type out the code from the book - and not even that seems to work! If it helps, the package javax.servlet doesn't seem to exist in JBuilder 8, from what I can see from the autocomplete. Any help would be greatly appreciated. Cheers in advance.
John Bonham was stronger, but Keith Moon was faster.
I have JBuilder 8. It does include javax.servlet. My guess is there's a package error. Are you sure you want to write the Test class in com.sun? If so, is the file placed in the folder /com/sun ? --Mark
Joined: Sep 23, 2002
Originally posted by Mark Herschberg: I have JBuilder 8. It does include javax.servlet. My guess is there's a package error. Are you sure you want to write the Test class in com.sun? If so, is the file placed in the folder /com/sun ? --Mark
All i want to do is compile this stub of code, and the statements above it. What do I have to do, to get it to work, then? What would you do to get the code to compile?? "If so, is the file placed in the folder /com/sun ?" What file do i place in com/sun? Should i place the test.java file in a folder called sun?? If so, where should this folder be on the hard disk??? Please help, as I am totally lost. And have spent too many hours breaking my thumbs, getting nowhere with it.
Joined: Dec 04, 2000
Are you familiar with packages in Java? Here are two references if you're not. Creating and Using Packages Java Package Tutorial You just need to make sure that your java file is in the right folder. If you check your project properties you'll see some working directory set for your project. Under the folder JBuilder will create a src directory where your java files will go. The directory structure under there must reflect the package struture, e.g. Working directory: C:/Old_D_Drive/Projects/HBS/JBuilderFiles/SimTrade Package: com.hbs.simtrade.test File location: C:\Old_D_Drive\Projects\HBS\JBuilderFiles\SimTrade\src\com\hbs\simtrade\test You really should put your classes in com.sun, since Sun will put its classes there and you might get a conflict. Instead, you should create packages like com.myCompany.test --Mark
"JavaRanch, where the deer and the Certified play" - David O'Meara
Joined: Sep 23, 2002
I installed JBuilder 9 to see if the problem could be rectified. It couldn't. Basically, the javax package exists, but javax.servlet is not in it, in either JBuilder 8 or 9 enterprise edition. I have been reading up on it. Don't I need to install a JSWDK, and point my JBuilder to this? If so, can somebody please supply the EXACT link i need to download the jwsdk. I have been to the sun site, and the download section, but have then been going round in circles for hours, trying to find the jswdk download link. [ August 30, 2003: Message edited by: Steve Jensen ]
I hate that JBuilder doesn't make the Servlet package available immediatly... If you are running the professional edition of jbuilder, you can just go to "File", "new", choose "web", and choose "servlet". If not, download the web development kit, and make it a library in JBuilder. Then add it to the "required libraries" for your project.
I have a vanilla load of JBuilder9 and mine wouldn't let me do the file, new, web, servlet choice as you outlined. However I do have the J2EE SDK installed and registered in my classpath statement. JBuilder still wouldn't compile the code listed above. Finally I clicked on "Tools" and then "Configure JDK's". Then with the java version on my machine selected in the left pane, and the class tab selected in the right pane, I clicked on "add" and browsed to where my jar file is located (D:/j2sdkee1.4/lib/j2ee.jar), clicked OK and then I was able to compile the file. I also had to add the test file to a project in order to get it to compile for me. After that JBuilder created the necessary folders beneath the source file's location to locate the .class file. HTH.