Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8603845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:25:13+00:00 2026-06-12T02:25:13+00:00

I have a java project, and need to write makefile to let it run

  • 0

I have a java project, and need to write makefile to let it run on Linux. My project includes external jar files and resource package(.txt resourses).I am really a newbie for Linux, and just learn how to write makefile.

My project structure

I refer to some materials and write a makefile like this:

# Set the file name of your jar package:
JAR_PKG = ADBproject1.jar

# Set your entry point of your java app:
ENTRY_POINT = adb/Bing_WebResults/Run.java

# Need resource directory
RES_DIR = yes

SOURCE_FILES = \
adb/jsonModels/Metadata.java \
adb/jsonModels/Result.java \
adb/jsonModels/Data.java \
adb/jsonModels/DataContainer.java \
adb/models/Weight_ID.java \
adb/models/Pair.java \
adb/models/Document.java \
adb/models/Collections.java \
adb/Bing_WebResults/Bing_Search.java\
adb/Bing_WebResults/Run.java \


JAVAC = javac
JFLAGS = -encoding UTF-8


vpath %.class bin
vpath %.java src

# show help message by default
Default:
    @echo "make new: new project, create src, bin, res dirs."
    @echo "make build: build project."
    @echo "make clean: clear classes generated."
    @echo "make rebuild: rebuild project."
    @echo "make run: run your app."
    @echo "make jar: package your project into a executable jar."

build: $(SOURCE_FILES:.java=.class)

# pattern rule
%.class: %.java
    $(JAVAC) -cp bin -d bin $(JFLAGS) $<

rebuild: clean build

.PHONY: new clean run jar

new:
ifeq ($(RES_DIR),yes)
    mkdir -pv src bin res
else
    mkdir -pv src bin
endif

clean:
    rm -frv bin/*

run:
    java -cp bin $(ENTRY_POINT)

jar:
ifeq ($(RES_DIR),yes)
    jar cvfe $(JAR_PKG) $(ENTRY_POINT)  -C bin . res
else
    jar cvfe $(JAR_PKG) $(ENTRY_POINT) -C bin .
endif

But I don’t know how to add those two external .jar files (gson.jar, commons.jar) into makefile. And I’m not quite sure, whether the file paths I wrote are correct.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:25:14+00:00Added an answer on June 12, 2026 at 2:25 am

    javac has a -cp and -classpath argument:

    -classpath <path>          Specify where to find user class files and
                               annotation processors
    -cp <path>                 Specify where to find user class files and
                               annotation processors
    

    They seem to be equivalent as far as the documentation is concerned.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a project that includes some Java APIs, some resource files, and some
I need to write a project that's only compatible with Java 1.5. I have
I am working on a Java project and need to have a keypress simulate
I have a Scala/Java dual language project where I need to pass a Scala
I have a project in Java and I need to make a code listing
I have a Java project in Eclipse with ~10 packages and ~10 class files
I have a project written in C++ and I'm looking to write a Java
I'm working on a Java project where I need to have multiple tasks running
I have been given a project where i need to write a program which
On large-scale Java/.Net Enterprise projects, does every developer need to have all the components/libraries/dependencies

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.