Solved

gnumake problem

Posted on 2002-04-09
2
183 Views
Last Modified: 2010-03-31
Having trouble getting gnumake to work (my first time, usually use IDE)

There is a difference between the location of the class files generated by “make” and where “make clean” looks to rm files. When doing a “make clean”, the window will show

make[1]: Entering directory `G:/Dev/Java/JProjectName
rm -f G:\Dev\JProjectName/classes\com\aaa\bbb\main\*.class

This doesn’t correspond to the location of the class files, which are in, for example,
G:\Dev\JProjectName/classes/src/com/aaa/bbb/main/JProjectName.class

(The difference being /src/)
Which is “correct”? That is, does /src/ belong in the path of the class files?  I suspect it does, because the package declaration in the java files contains “src”
That being the case, what needs to be done to get “make clean” to use the correct path?

It also concerns me that there both \ and / in the some statements, but that may not be an issue.

Various info:

JAVA_DEV_ROOT = G:\Dev\Java\JProjectName
JAVA_HOME = C:\jdk1.3.1_01
IS_UNIX = null

Variable values when debugging main makefile

PACKAGE = com.aaa.bbb.main (or com.aaa.bbb.foo2, com.aaa.bbb.foo3)
(one would think this should be src.com.aaa.bbb.main)
PACKAGE_LOC = com/aaa/bbb/main (or com/aaa/bbb/foo2, com/aaa/bbb/foo3)
DESTINATION = G:\Dev\Java\JProjectName/classes
PACKAGE_DIR = G:\Dev\Java\JProjectName/classes/com\aaa\bbb\main (or…)

Directories in the root are:
G:\Dev\Java\JProjectName\classes
G:\Dev\Java\JProjectName\jar
G:\Dev\Java\JProjectName\make
G:\Dev\Java\JProjectName\src

/src/ contains packages:
com/aaa/bbb/main
com/aaa/bbb/foo2
com/aaa/bbb/foo3

Actual paths are:
G:\Dev\Java\JProjectName\src\main
G:\Dev\Java\JProjectName\src\foo2
G:\Dev\Java\JProjectName\src\foo3

The Project makefile (G:\Dev\Java\JProjectName\makefile) is:
PACKAGES = \
   com.aaa.bbb.main\
   com.aaa.bbb.foo2\
   com.aaa.bbb.foo3\
NODOC_PACKAGES = \
JBBB = \
     jprojectname.jar \
JBBB_3RDPARTY = \
MAIN_CLASS     = JProjectName
MAIN_PACKAGE   = com.aaa.bbb.main
MAIN_JAR       = JProjectName.jar
RUN_PARAMETERS =


A package makefile (e.g. G:\Dev\Java\JprojectName\src\com\aaa\bbb\main\makefile) looks like:

PACKAGE = com.aaa.bbb.main
SOURCE  = \
     JProjectName.java \
RMI_SOURCE =
MAIN  = JProjectName.java
include $(JAVA_DEV_ROOT)/Makefile


Example package declaration in a java file:
package src.com.aaa.bbb.main;


Another symptom:

When doing a "make run" I get a NoClassDefFoundError

G:\Dev\Java\ JProjectName >make run
c:\jdk1.3.1_01/bin/java -classpath c:\jdk1.3.1_01/jre/lib/rt.jar;;G:\Dev\Java\ JProjectName /classes;G:\Dev\Java\ JProjectName/jars/jprojectname.jar; com.aaa.bbb.main. JProjectName \

Exception in thread "main" java.lang.NoClassDefFoundError: com/aaa/bbb/main/ JProjectName
make: *** [run] Error 1


0
Comment
Question by:jdaues
2 Comments
 
LVL 7

Accepted Solution

by:
Igor Bazarny earned 100 total points
Comment Utility
Well,
I guess you either need to change PACKAGES value and something not shown here in your build script--it decides to put src between JAVA_DEV_ROOT and package directory, or don't start your package with src. Second option looks right to me, by naming convention your package name should start with your company domain name in reversed order, I doubt it's aaa.com.src.

Generally, your project structure looks OK, when package name doesn't start with src. src/com/aaa/bbb/File.java compiles to classes/com/aaa/bbb/File.class. You have separate directory for sources (src) and package structure below it and directory for compiled classes (classes) with same structure below

Regards,
Igor Bazarny,
Brainbench MVP for Java 1
0
 

Author Comment

by:jdaues
Comment Utility
Originally, I didn't have "src" in the package names, but in hacking at it to get it to work I added it, though it didn't feel right.  So I have removed it on your advice.

I am compiling the project both with gnumake and with an IDE (Eclipse) and this turned out to be the issue because I had root directory the same (G:\Dev\Java\JProjectName) for them, when in fact they should be different.  For gnumake, the root should be G:\Dev\Java\JProjectName and for Eclipse it should be G:\Dev\Java\JProjectName\src  

So now all is well, thanks.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bunnyEars2 challenge 6 66
wordappend challenge 8 82
Unable to start eclipse ? 17 82
Problem to start Neon 20 48
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now