Java: how to compile a huge behemoth of source code - java

I've downloaded a big java program in raw source code. How can I compile it? If I try to compile classes with javac I only get errors.
I guess I have to use eclipse? Can anyone point me to a guide on how to compile such a large project in eclipse?

Edit: As some people pointed out, Eclipse does not use the javac compiler. Oh well, we live to learn. That does not change the rest of my answer.
You have to realize that Eclipse uses javac to compile the source code. So, if you can't do it, chances are Eclipse won't do any good either.
It's highly unlikely that all the files are part of the same package/component. You have to figure out (based on the errors), what is the packages organization and the build order.
However, I would suggest you to look around for a build.xml or a Makefile somewhere close to the top of the tree. If you fidn the former, you could try using ant (automated build tool) with it; if you found the latter, try make on it.

Related

Ant javac ignore missing imports

i am trying to port a build from Eclipse to use "standalone" ant, there are a lot of linked files/folders and also some cycle references(If i export via Eclipse it is working).
I was trying to find a way to make the javac ignore if a java file was not found.
Is this even possible with ant?
And if not, is there any chance i could be able to get a working build perhaps with an other build tool?
thanks in advance
I was trying to find a way to make the javac ignore if a java file was not found.
Don't. Instead, make sure you supply all the code you need.
What would you expect the compiler to do if you start using a type which it knows nothing about? Java just isn't designed to cope with the situation.
If Eclipse can build the code without errors, then everything should be available - you should track down every missing file rather than trying to ignore them.

Recompiling TJWS

I am new to java and i have to make some changes to Tiny Java Web Server(LINK) and recompile it.
Can someone please explain how it is done in java?
Usually i have been using javac command for compiling, but here i have multiple files to compile.
Also, i have read someone i should be using ant , but it seems complicated.
Why does compiling a program have to be so complicated in java?
Can i compile it somehow using eclipse?
Answering your implied question "why can't all Java programs be compiled using Eclipse" -- you see, there are tools which compile Java programs consisting of many files (not just one), and these tools perform compilation automatically, without human operator, without using Eclipse (or any other IDE), so they need a compilation program. One such program is Ant, another popular in Java world is Maven.
Another point for Ant is that often you need just to compile program, not to edit it in anyway, so you don't need IDE, only compilation tool.
If you interested in understanding how these compilation tools work, I would suggest starting with Ant, then proceed to Maven (if needed).

How to make javac squawk for incorrect package names in Java source files

Today, I ran into a java source file that had a typo in the 'package' statement at the top. The name of the package did not match the name of the directory the file was sitting in (one extra 's' at the end).
To my surprise, javac from 1.6, checkstyle, and pmd all passed the file as OK. The only tool that got around to complaining was javadoc, and only because it was the only file in the package, and a package with no classes in it is a fatal error to javadoc.
Is there some option to javac, or some other command-line tool (preferably with a maven plugin maven) that will squeal about this sort of goof?
I tested this with the latest version of Eclipse and it complains. Eclipse has Maven support.
Well, this seems like an interesting "feature". I fight with such errors regularly once a year. I would guess that PMD, FindBugs or a tool like that will find these errors. However if you say they do not, I can think of only three other options at the moment:
Use Eclipse compiler from Maven (to compile the sources and see the error). This should be possible although I have never tried it so far.
Create a custom PMD rule that will check the Java package name and compare it with the directory name.
Create your own Maven plug-in that will check it. This may not be very easy if you have not develop a Maven plug-in so far.
These are just ideas and should be treated as such.

How can I compile and run a Java program?

How can I compile and run a Java program?
http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html#win32-2b
Is English difficult for you? There are tutorials for your language too.
to compile:
javac path/to/file/with/main.java
then to run:
java path/to/file/with/main
I would suggest that if you are starting with the java language, first use an IDE (Eclipse, Netbeans, Intellij IDEA or another. For a first step let the IDE do his job. Then once you evolve quickly use a build manager (Ant, Maven, Gradle, ...). It is a good practice to always have a build manager in place to keep the build in control.
To compile (assuming you are in the same folder as the file is)
javac "filename.java"
To run
java "filename"
make sure you have set the environment variables correctly, so that the command line can detect where javac is.

Compiling J2ME from command prompt

I'm trying to compile the J2ME java files from command line from 2 week ago !at now I can compile project successfully and also create JAR and JAD files . The files that I compile work equivocal, this means if I use basic class the same as TextField or Form or others this work successfully but if I use RecordStores OR more important if use Resource(s) AND Library(s) the result is not good and program can not work.
I do not know what 'compiling from command prompt' means, but You should really take a look at Ant and it's extension Antenna for J2ME apps building.
Antenna should be really easy one for starting the development and just for compiling/creating distribution package. And it makes including thirdparty jars just a breeze :)
Besides using some IDE plugins I'm sure you will not get a better answer then this.
/Jaanus

Categories

Resources