Compile vtd-xml linux? - java

How should one compile vtd-xml for java on a linux box? I downloaded the project from sourceforge, but it only comes with a .bat script. I set classpath to reference the jar file, but I get all sorts of symbol not found errors when I try to run my compile my own script. I think vtd-xml needs to be compiled as a project before I can use it in other scripts, but I don't know how. I'm new to java...

you should not. Go to https://sourceforge.net/projects/vtd-xml/files/vtd-xml/ximpleware_2.12/VTD-XML%20Standard%20Edition/ximpleware-2.12-java.zip/download
And download the zip, it has been verified to work...
Just put vtd-xml_2-12.jar in your classpath
Disclaimer: I am the author of vtd-xml.

Related

How to use apache commons io for Java in Linux terminal?

I tried to compile (using only javac filename.java) a class with the following import:
import org.apache.commons.io.FileUtils;
This threw an error: "package org.apache.commons.io does not exist".
So after some googling I realized that I need some sort of commons-io .jar file and that I can try to compile with something like,
javac -cp .:common-io-xx.jar filename.java
I guess the xx part is a placehodler meant to be replaced when I know the proper name of the file that I'm trying to add to my classpath (tell me if I'm wrong).
I tried finding this .jar file but on the following site:(http://commons.apache.org/proper/commons-io/download_io.cgi) I could only find some .tar files which as far as I could see did not contain any .jar files. Thus I need help with two things:
1) Where can I find the correct file containing the source code I need to use the commons-io library?
2) Upon finding that file, how do I successfully compile (and run) my program in the Linux terminal?
Please note that I am completely new to the concept of classpath and need help with how to apply this in the terminal.
I know similar questions have been asked before, but none so elementary that I could use their answers, I'm afraid.
1) You don't need the source code of commons-io in order to compile your code. As you have been trying to do, you just need the commons-io jar file. If you are interested learning how the code works in that particular jar, a quick google search will bring you to this github repo: https://github.com/apache/commons-io
2) The files from http://commons.apache.org/proper/commons-io/download_io.cgi are compressed files. The easiest option for you is to download commons-io-X.Y-bin.zip (replace X and Y with whatever version you are looking for). Unzip the zip file you downloaded (https://unix.stackexchange.com/questions/156261/unzipping-a-gz-file-without-removing-the-gzipped-file), then compile with the command you have above (make sure your classpath, source file locations are correct).

Compile Java source to another directory

so I'm fairly new to Java programming and I can compile and run Java code from the Linux terminal using javac objects.java and java objects. Although, I was wondering on how I could compile the source code to another directory? Let's say I have the file person.java in the /home/alarm/projects/src/ folder, but I want to compile it into the /home/alarm/projects/bin/ folder while still in my current directory. Not sure if that makes any sense, but can anyone explain this if possible? Btw, I am using Arch Linux just so you know my OS.
You can use the parameter -d to specify the target directory.
More information can be found here.

Compiling source code makes .jar significantly smaller?

///WARNING- I DO NOT KNOW ANY LANGUAGES/HAVE NO USED ECLIPSE BEFORE\\
I'm currently trying to get a .jar file compiled in Java8 to compile in Java7, but seem to be having trouble, I have the source code intact so that is not the problem. It compiles fine, but the finished .jar is smaller than the original by a large margin. I believe the problem lies in my inexperience with Eclipse meaning I problably did something wrong.
Source Folder Structure
src\com\darkblade12\enchantplus...java files
Contents Of Each Folder
If you have some doubts about eclipse being behind the problem, try to compile it directly using the Command line Interface with the target version version of java by using javac.
Example for Windows:
set JAVA_HOME=C:\Program Files (x86)\Java\jre1.7.0_21
javac com/darkblade12/enchantplus/*.java
jar cvf program.jar -C com/darkblade12/enchantplus
Then compare your jar generated by eclipse and this generated directly from the command line.
Another way to verify is to open the jar file with and archive manager like 7-zip and verify its content.

What is the difference between the Apache sources.jar and .jar files?

I'm curious about Apache commons-io, why do they include a sources-jar inside the code package. We will not compile the program like so :
javac -cp .;.\lib\commons-io-2.4-sources.jar myCode.java
But we compile it like this :
javac -cp .;.\lib\commons-io-2.4.jar myCode.java
So why do the libraries also include a -sources jar in the download code ? I'm guessing it's for studying the source code, if we want to add/improve ?
The source JAR is so you can read the code is you want to. If you use an IDE, it can know to down load this JAR and if you look at a class in it, it will show your the source. esp useful when debugging a program. If you are not using an IDE, you can unpack the source and read it to understand what it is doing.
The reason the source is not included in the compiled JAR is so it can be easily dropped if all your are doing is running the program e.g. in production.

How to compile a single Java file

I have searched this, but I could'n find or understand what I found.
Now I'm not a Java programmer, but I have the need to compile a single Java file into an existing (compiled) Java program. The source of this Java code is not available to me, therefore I cannot compile the entire project.
I'm not interested in decompiling the original project.
How to quickly do this using only the JDK and javac? (Through the command line is what I prefer.)
I understand that to do so error checking outside of the single java file will have to be disabled, because it can't read the dependencies.
Thanks in advance,
-Aidiakapi
EDIT: I do have the JAR file, thanks for the answer :)
As far as I can understand you want to re-compile a single java file and replace it in an existing jar file..
So you compile it..
cmd>javac -classpath jar1.jar;jar2.jar my.company.MyClassToReplace.java
and replace it in the jar.
cmd>jar uf myJarFile.jar my/company/MyClassToReplace.class
You need to have the jar(s) which contains all the things your class depends on to compile it.
You can then compile the Class with
javac -classpath jar1:jar2 mypackage.MyNewClass
If you have no access to the original Jars, you will have to create mock classes and method etc (which don't have to do anything, just be there so your class compiles) Using an IDE can make both processes easier. (That is what it is for ;)

Categories

Resources