I've looked at several questions and read through a couple of tutorials but MakeFile is still a bit of a confusing concept to me.
From what I understand, it is essentially a set of rules for building up Unix commands to compile and run the code?
So far, I have been just running my Unix commands as such:
>> javac Main.java SomeClass1.java SomeClass2.java
>> java Main input_file.txt
because my Main function takes in an input_file.
I want to be able to make this more efficient by using Make, but I am having trouble with understanding the concepts.
Any help is much appreciated!
Thank you!
Make is a build tool - a piece of software to compile the source code of software projects into an executable.
When you are creating small, simple programs, you don't really need a build tool. You can just compile your code by running the compiler javac on the command line. But when you start working on a larger project with many source files, it's going to be too cumbersome to compile all the source files by hand. You'll want to use a build tool. Besides compiling your code, a build tool can help you perform other tasks, such as automatically running unit tests and automatically managing dependencies (libraries that your program needs).
For a Java project, consider using a Java build tool such as Apache Ant, Apache Maven or Gradle. Those are the de-facto standard build tools for Java projects, and the big Java IDEs (Eclipse, IntelliJ and NetBeans) have support for these tools.
Make is mainly used for C and C++ projects and is not very well suited for Java.
Related
I am trying to work on a desktop application using JavaFX/Java that requires me to compile and run c++ and Python code when it's requested, offline. I was wondering if this even possible?
How can this be done? Are there any libraries that can compile other languages' code and run them, which can be added in JavaFX/Java environment? Or do I need the user to install c++ compiler and Python in their machinees and then somehow integrate those tools in my application?
I would appreciate any help or insight.
Packaging a C++ or python compiler into a Java application is impractical. Your system would have to store, unpack and install each compiler into the local directory, resulting in a massive file size, it would also take a very long time.
The best method is to require that the user have those compilers installed or provide them with the install utilities so they can install them separately.
Once the compilers are installed you can get Java to run a shell script which builds and compiles the files.
I hope that solved your question, if you need any further clarification please feel free to reach out to me.
Sincerely,
Owen
I'm just about starting to learn Java. Reading about, I installed Netbeans.
Running Apache Netbeans IDE 11.2.
The Java version is 13.0.2.
I'm promptly follow the Quickstart guide on the netbeans website.
File>>New project>> Java >> Java Application.
Errhmm, I don't have this 'Java' option. All I have is
So what's the difference between Java & Java with Maven/Cradle/Ant . At this point in time, I intend to start with basics of Java programming and then move on from there. SO which option am I meant to be starting with? If I'm missing Java, how can I add it ? Going through the installation procedures didn't give me any option to choose from.
p:s - this is all running on Mac OS Catalina
You can start with any of Java with ... option. I use Java with Ant option.
Maven, Gradle, Ant are build-tool addons i.e. they provide additional support if you intend to use any of these as your build tool.
When you choose Java with Ant option, it will let you create, compile, debug and run your Java programs without requiring anything additional. After using this option, you will get an interface as shown in the screenshot given below:
Maven, Gradle and Ant are build tool which allows you to compile, unit test, package and (if you like) even deploy your Java applications (they do support other languages btw).
I suggest you to start with one of those (Maven is very popular and probably a little bit easier than the others) instead of relying on your Java IDE specific features.
Once you master a build tool you can change IDE (IntelliJ is also a very good option ;-)) and will still work as before. You also find plenty of resources and help (like Stackoverflow) if you need hit some problems.
Best of luck!
I work on a project which has a large C++ code base, and a large Java code base. We are in the process of migrating the C++ build to CMake, which should help us address our build issues on the C++ side.
On the java side we have the problem that our build is not incremental, which has become a major resource suck. I understand that Gradle, Ant and Maven are capable of running incremental Java builds. But since we are already using CMake on the C++ side, I'd like to know if it is possile and reasonably easy to set CMake up to build our Java code incrementally.
To make a well formed question out of this:
Is it possible to perform an incremental java build with CMake?
If possible: How, and what are the pitfalls?
I have inherited someone else's code. He used CMake to build the fragments for C++ and the fragments for Java/Android. I cannot believe that he would have used Notepad and Windows Explorer to manage his package/class structure and implementation. Is there a code manager tool or IDE that allows you to put your Java code in one package and your C++ in another package? The CMake scripts would build the projects separately, of course.
CMake is just a build tool.
You can use any IDE you like to write the code and then use a different tool to build it.
Eclipse supports both Java and C++, but I wouldn't recommend it for either.
This is in regards to building a Java Project.
So I'm a bit confused on my options here.
My requirements (it's a small project):
Needs to compile Java project with specific/custom compiler arguments
Project has native libs that need to be included
need to compile javascript->java class via Rhino javascript compiler (https://developer.mozilla.org/en/Rhino/JavaScript_Compiler)
After the build I need to run another command: ProGuard (http://proguard.sourceforge.net/)
run javadocs
Package everything up in Jar (also including external data, ie, images, xml, ini, etc)
Build/create a .jnlp web start.
Available under both Win and Linux would be optimal.
this is a hobby project, so don't want to spend weeks learning/managing the build system. At most an 8-12 hour investment start to finish (otherwise it's just better to keep doing everything by hand).
btw, my IDE is Eclipse if it matters; a nice integrated plugin would be nice - but not required.
So far I think Ant and Maven are the main two build systems in use. It's very unclear to me though which one I should use or how they differ?
The other option would be 'make' under linux (or maybe cygwin). I've only used it once, but seemed pretty quick to get going/working. Is that a good option for Java or this project? Any downsides to make? Why don't more java developer's use it?
Other options?
In a nutshell: spend your 12 hours learning and using Ant.
Maven has a good feel out-of-the box, super-easy to get going and with the neat dependency management, but down the line tweaking the pom.xml (your project's maven build file) to fit your needs will require more fiddling with than if you used Ant.
To address some of your specific requirements:
you can use <compilerarg> elements with the <javac> task
for native libs you can add them with: <sysproperty> and key="java.library.path"
use Rhino with Ant (http://stackoverflow.com/questions/3526960/using-recent-rhino-in-ant-script)
there is a Proguard task for Ant (http://proguard.sourceforge.net/index.html#/manual/ant.html)
for javadoc Ant comes with the <javadoc> task out of the box
the <jar> Ant task is extremely easy to use to package everything up
there is a <jw:jnlpwar> task available from the [Ant Web Start Task project] at (http://ant-jnlp-war.sourceforge.net)
Ant is ubiquitous, it works for just about every major platform out there (Linux, Unix, Windows, MacOS)
with plenty of docs and examples available on the web, you'll pick-up Ant in no time, and those hours you'll spend learning it will probably "pay" themselves back within a couple of weeks of using it for your builds.
Eclipse integrates with Ant out of the box (http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.platform.doc.user/gettingStarted/qs-81_basics.htm)
It may not do fancy dependency management out-of-the-box like Maven (although for that you can integrate Ant with Ivy) but it certainly provides you with all the flexibility you'll ever need, and you won't find yourself "fighting" the build tool configuration file as it's fairly common with Maven.
I should probably just mention the 2 new names in Java build (and CI) tools: Hudson and Jenkins. They're fairly recent and may be interesting to look at, but I would definitely not recommend them to you and your project at this early stage.
Note: apologies for the lack of real links (only allowed 2 links atm)
Maven is the best choice here as it has integration for all of these
so go for it.
Here, quick links for you to save an extra hour to spend on learning maven ;)
Maven Compiler Options
Native Maven Plugin and Projects with JNI
Use Maven Antrun Plugin to Run rhino compile ant task
Use Proguard Maven Plugin (further details)
Maven Javadocs Plugin
Maven Assembly Plugin
Webstart Maven Plugin
Its java based so supported by most OS that support java !
It depends how quickly one can learn but AFAIK 12 hrs is sufficient to get started