This week's book giveaway is in the Open Source forum.
We're giving away four copies of Programmers Guide to Apache Thrift and have Randy Abernethy on-line!
See this thread for details.
Win a copy of Programmers Guide to Apache Thrift this week in the Open Source forum!
  • 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

could not load main class: makefile  RSS feed

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have below directory structure and have also create makefile in order to compile and run the files

Directory Structure

mqtt_client/src/edu/mqtt/au/*.java (all java files)

After running make all my compiled classes are stored under classes folder

mqtt_client/classes/edu/mqtt/au/*.java (all class files)

makefile content




When I run make command ......all java files compiles properly but when I run make run it gives me below error



Please suggest where I am going wrong


 
Saloon Keeper
Posts: 5475
143
Android Firefox Browser Mac OS X Safari Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's been about 20 years since I used make for Java projects... any particular reason you're not using something like Ant or Gradle?
 
Surekha Gaikwad
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no specific reason.....but its being asked us to do in assignment so cant help out
 
Bartender
Posts: 20721
124
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason why tools like Ant, Maven and Gradle exist is that make is an absolutely horrible tool for building Java projects. It doesn't understand how to properly handle Java inter-dependencies.

It's really probably worse than just simply using .BAT files, speaking as one who long ago tried both before discovering Ant, then Maven.

If you have serious aspirations to use Java for real-world sized projects, make it a priority to learn one of the Java build tools. Make will only give you ulcers. Plus nobody in the industry uses it for Java, since we've already got lots of other ways to get ulcers.
 
Master Rancher
Posts: 4072
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried running from the command line from the directory you run make?
java -cp .:./classes edu.mqtt.au.Subscriber
 
Surekha Gaikwad
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I tried that way as well but it still not able to find main class ......I dont know why its happening that way
 
Saloon Keeper
Posts: 10206
216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ehh, isn't the delimiter in classpaths the semi-colon character and not the colon?
 
Marshal
Posts: 64471
225
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Ehh, isn't the delimiter in classpaths the semi-colon character and not the colon?

Isn't that ; on a Windows® box and : on a *nix box?
 
Sheriff
Posts: 6738
466
BSD Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know the makefile stuff, but I know how to run Java. Can you show tree of the current working directory where you were running command what Dave suggested?
 
Liutauras Vilda
Sheriff
Posts: 6738
466
BSD Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please also show the package declaration of Subscriber class (from source file).
 
Tim Holloway
Bartender
Posts: 20721
124
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I'm going to repeat myself.

From bitter experience, I can say that using make to build Java products is a complete train wreck. It will attempt to do things you don't want, and it won't do things you need it to do.

That said:

1. Show us a directory tree listing of your classes directory.

2. MAKE SURE that file src/edu/mqtt/au/Subscriber.java defines this method:



It must be done exactly so. If it's not static and/or doesn't "return" void and/or doesn't take exactly one and only one argument: an array of java.lang.String, then the JVM will not recognize it as an executable main method. All items must appear in uppercase/lowercase exactly as indicated. Java is case-sensitive. And if the method isn't declared as public the JVM won't see it even if the other signature characteristics do match.

And as an additional note: Windows is generally not case sensitive to file and directory names. Java, however is. That means that you can create files and directories whose named are spelled properly, but Java won't see them if they are mis-capitalized.
 
Sheriff
Posts: 21741
102
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:2. MAKE SURE that file src/edu/mqtt/au/Subscriber.java defines this method:



It must be done exactly so.


Well, it can have one other form, using varargs:

It can also declare any exception in the throws clause.
 
Surekha Gaikwad
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well this issue is resolved.........thanks guys for your response
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!