0

I feel like a 4-year old who has a slice of bread with pb and a slice with jelly and is asking how to make a sandwich..
I've been given the responsibility of maintaining a javaEE website that was done by our parent company that no loner supports us. I'm relatively new to JavaEE and I'm trying to figure out how to recompile the files that need to be modified from within the root folder of the site.
I downloaded NetBeans to help me with this, but still can't figure it out. My problem is that the java files can't find any of the packages and resources they are dependent on. As far as I know, the resources are there.. although, I do see some packages starting with "com." and "javax.", and I don't see a 'com' or 'javax' folder anywhere.. I believe my problem has something to do with setting the class path in the project properties in NetBeans.. I tried that but either I'm not doing it right, or its not working. This whole Java compilation is so foreign to me, it'd be really great if someone could lead me in the right direction of getting this website compiled.
I posted a pick of the folder hierarchy of the website to help:

site hierarchy

I'm trying to compile the RecordAdd.java file here specifically at the moment. Some of the packages it is trying to import come from its parent folder, asp, of the folder it is in, easp. The file is also trying to import com.icesoft.faces.component.*; where '*' consists of several different imports of the parent packages. I don't see a com folder like I mentioned, but I do see icefaces.jar files in the lib folder in WEB-INF folder. I've tried putting these folders in NetBeans Library-Compile category classpath, but that didn't do anything.
I'm not doing something right, that is probably a basic knowledge of compiling java projects, but I'm just not getting it. I really appreciate any help, just please don't be too harsh. Thanks!

Nick Rolando
  • 25,879
  • 13
  • 79
  • 119
  • javax is for oracle only so you won't see that in your packages. – Abdullah Jibaly Jun 17 '11 at 19:10
  • Then what is the purpose of having this import in the code file? – Nick Rolando Jun 17 '11 at 19:13
  • There are lots of libraries provided by Sun/Oracle that come with java and you have to import them to access them. – Abdullah Jibaly Jun 17 '11 at 19:15
  • Similarly your com.icesoft... package, the import is referencing classes in that jar file you see in WEB-INF/lib. – Abdullah Jibaly Jun 17 '11 at 19:16
  • Basically you can import anything you have in your classpath. By default all the java libraries are in your classpath and in web apps everything in the WEB-INF/lib and WEB-INF/classes are usually in your classpath. – Abdullah Jibaly Jun 17 '11 at 19:17
  • Have you already imported the project in netbeans? If the project was created in netbeans, and have been successfully imported in netbeans, I think you don't need to compile a java file to see if there is any problem with it, netbeans automatically detects and sets the error icon on the java file that has problem, under the project tree. – Bhesh Gurung Jun 17 '11 at 19:22

3 Answers3

4

Try to find out which IDE the original devs used. I see a nbproject folder which indicated Netbeans (unless that was created by you) so try opening the project in Netbeans as a Java EE project. I'd also try to open it in Eclipse, it has good importing capabilities and can sometimes figure out the classpath on it's own. Download the Java EE version of Eclipse and install the Web Tools Project. You can also try to see if there is a build file that will compile and generate a war file for you (something like build.xml).

Abdullah Jibaly
  • 53,220
  • 42
  • 124
  • 197
  • The original devs did use NetBeans, though nbproject was created by me. I do have a build.xml file. You mean compile it with javac.exe like i would a .java file? – Nick Rolando Jun 17 '11 at 19:19
  • No, it will probably be difficult to compile it using javac because of all the classpath dependencies. You can install ant (or use it from Netbeans) to compile the webapp. There should be a target that compiles and creates a war file. – Abdullah Jibaly Jun 17 '11 at 19:21
  • netbeans compiled build.xml file fine, but I don't a .war file anywhere. In fact, the whole project builds fine, but won't run, and won't spit out any .class files (please see my comment to jpredham's answer) – Nick Rolando Jun 17 '11 at 21:17
  • Would it make any more sense if I said they deployed this to our server (without any netbean files or references), and I copy and pasted it from the server to my localhost? This is an older application and the parent company is located in Taiwan.. – Nick Rolando Jun 17 '11 at 21:59
  • If all you want is that compiled class file then you probably don't need to build anything. Netbeans automatically keeps the compiled .class files in the build directory for the project (go to the project properties to see where that is). You can usually see them using the navigator view or just use windows explorer. You won't see them in the regular project view (it only shows source files). – Abdullah Jibaly Jun 17 '11 at 22:05
  • Re: copy and paste from the server it doesn't help except that means that it's not necessarily the same project structure as they had in Netbeans although I'm willing to bet that they just copied and pasted whatever they had in the ASP project into tomcat/glassfish or whatever container that is. – Abdullah Jibaly Jun 17 '11 at 22:08
  • The build folder is empty :( and yes, I'm sure they just copied the necessary files from their netbeans project over to the live server. Do you have any other suggestions? – Nick Rolando Jun 17 '11 at 22:36
  • Based on your screenshot above it looks like the project is configured to place the .class files right alongside the .java source files. If you delete or move the .class file you should see it get re-generated. Is that what you need? – Abdullah Jibaly Jun 17 '11 at 23:11
  • Yes it is! As you can see in the pic above, I removed the 'RecordAdd.class' file in hopes of this, but it doesn't recompile the file and spit out the .class file. A new .class file compiled from my java file is all I need. But I need to get the references working in order to compile it. – Nick Rolando Jun 17 '11 at 23:18
  • What you need to do is tell us what Netbeans is complaining about then because it's obviously not compiling the project correctly. You can see the errors from the Task List window as well. – Abdullah Jibaly Jun 17 '11 at 23:21
  • "Error occurred during deployment: – Nicklamort 2 hours ago "There is no installed container capable of handling this application domain2. Please see server.log for more details. C:\Program Files\glassfish-3.1\glassfish\domains\domain2\nbproject\build-impl.xml:260: The module has not been deployed. at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment‌​.java:187) at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:106) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) at sun.reflect.GeneratedMethodAccessor170.invoke(Unknown Source) – Nick Rolando Jun 17 '11 at 23:27
  • There should be errors before the deployment process (compilation errors). Do you not see any red flags in the project view? – Abdullah Jibaly Jun 17 '11 at 23:32
  • Might want to give Eclipse a shot as I mentioned earlier, you have nothing to lose if you're not getting enough error reporting with netbeans. – Abdullah Jibaly Jun 17 '11 at 23:33
  • Yes, Basically 95% of the import statements are erroring out because it can't find the specified "symbol", or the package simply "doesn't exist". – Nick Rolando Jun 17 '11 at 23:42
  • Something to look into: your classes (RecordAdd for example) are in a folder called easp within a folder called asp in WEB-INF. Typically this should correspond to a package declaration of `package asp.easp`. IS that what you see in the java file? – Abdullah Jibaly Jun 17 '11 at 23:57
1

It should be simple if the project was created in netbeans. Just go to File -> Open Project. Navigate to where the project is located. You will know if the folder is a project, because netbeans recognizes it and a different icon is displayed instead of a regular folder icon. Once you open your project, you can right click compile the project. You don't use java compiler yourself to compile java files in a project. Compiling and building are done by tools like ant, maven... It's automated.

Bhesh Gurung
  • 50,430
  • 22
  • 93
  • 142
  • It was compiled originally using netbeans, but I believe the developers took out netbeans files for production. I did "Open Project" and opened it, and netbeans created its own files for it. I'm trying to generate a new .class file by compiling the .java file. In netbeans, I build the project, and it says it builds fine, but I can't run it, and no .class file is outputed. Also, when I open the file in the editor, it shows me all the errors that it can't find the packages – Nick Rolando Jun 17 '11 at 21:00
  • To compile just RecordAdd.java, start with a new web app project in netbeans. Then copy the whole content of the src folder (the one at the very bottom of your picture) into the src folder of you web project in netbeans ide. Then right click the project -> properties -> libraries -> click add jar and navigate to the lib folder that's under the WEB-INF directory in the your picture and select all the jars (or do one by one if want to know which jars are necessary to compile that particular file). Everything you see under classes folder in the picture are generated after you build the project. – Bhesh Gurung Jun 18 '11 at 18:41
0

Importing existing projects into netbeans is a great way to loose a half a day. I'm assuming that since there's a nbproject directory, this was built through netbeans, which should give you a leg up.

  1. In the "Open Project" wizard, the top level of your application (not necessarily the sources) should have a friendly globe icon for a web application (.war) or a triangle for EE application (.ear). Open the triangle if there is one. Web applications can be packaged with EE applications through netbeans, so if the Web App you're trying to compile belongs to one, some of the build properties may be associated with it.

  2. Looking at the file nbproject/build-impl.xml should give you hints about where your libraries folder was located. Make sure this path matches in your project properties under the Libraries header. These libraries can be shared among projects and therefore likely out of this projects directory structure and referenced or native to this project alone in which case jars are copied in to your lib folder.

  3. There may be additional reference or server issues that netbeans detects (and gives a paltry error message for) which can be found in the project context menu under "Resolve Reference Issues" or "Resolve Missing Server". In netbeans projects are built against the servers they're run on right in the IDE. Check that you have the servers you want configured under Tools-> Servers, then ensure that server is linked in your project properties under Run.

This may not solve all your problems, but is a good start. Good Luck!

jpredham
  • 2,149
  • 1
  • 23
  • 37
  • The nbproject and build.xml files were created by me when I imported the project over to my localhost. I do see a .ear file, but I believe that was created by me, not the original compilation. – Nick Rolando Jun 17 '11 at 21:03
  • You wouldn't see an .ear file unless it was successfully compiled – jpredham Jun 17 '11 at 21:06
  • When I build it, it builds fine, but it doesn't spit out a .class file for the .java file I'm trying to modify. Plus when I open the .java file in the editor, it shows me boatload of errors of all the packages its trying to import but can't. Plus, even tho it builds fine, I can't run it: "Error occurred during deployment: – Nick Rolando Jun 17 '11 at 21:11
  • "There is no installed container capable of handling this application domain2. Please see server.log for more details. C:\Program Files\glassfish-3.1\glassfish\domains\domain2\nbproject\build-impl.xml:260: The module has not been deployed. at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:187) at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:106) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) at sun.reflect.GeneratedMethodAccessor170.invoke(Unknown Source)...." – Nick Rolando Jun 17 '11 at 21:11
  • If the enterprise project builds ok and the source you're trying to edit/build has missing libraries then that source is most likely not packaged in the enterprise archive. Check what components are packaged in the project properties under Build -> Packaging. – jpredham Jun 17 '11 at 21:35
  • Example. I have a "ClientMetricsAPI" enterprise application. Packaged in that archive is a "ClientMetricsAPI-war" project that contains code for a web application. When I build the enterprise app, it builds the web app since it's a dependency, generates the WAR file, and packages it in the EAR file. – jpredham Jun 17 '11 at 21:37
  • Ok. Archive File Name: Domain2.ear; Content to exclude: **/*.java,**/*.form,**/.nbattrs; And nothing is in the additional content to include. – Nick Rolando Jun 17 '11 at 21:40
  • I don't know what any of that means.. this java stuff is so foreign to me. I know java code, but no clue how to link stuff, compile projects, or anything. Could you dumb it down for me? – Nick Rolando Jun 17 '11 at 21:45
  • Sorry if I'm being vague, there are two types of Java EE projects at play here. An Enterprise type and a Web type. Both have their own build files, sources, and libraries. Enterprise projects typically don't have sources of their own and are used to bundle several projects and libraries together. The Domain2 project doesn't actually contain the project that your source belongs to yet. You should try to find the Web Application that contains your source (Maybe it's Called ASP?), fix the imports in THAT project by adding the required Libraries, then add it to the Domain2 archive list. – jpredham Jun 17 '11 at 22:27
  • I don't know how to add the libraries, that's my problem. I've tried everything I can think of..adding all kinds of "libraries" to the library in the project properties. I replaced the whole project with just ASP subfolder and did the same and am seeing the same resutls :( – Nick Rolando Jun 17 '11 at 23:39