A step by step tutorial on how to generate PDF files in Java. Describing a system for “checking-in” to a location using QR codes in Java. Below, you will also find examples of code to scale and to calculate coordinates for. How to create pdf in java using iText,iText image insertion in pdf, inserting table in itext pdf file, inserting list in itext pdf, new line in itext pdf.
Ranch Hand
posted 4 years agoI am trying to create a file on Linux machines using Java code.
Using the code I am able to create a file on Windows but the jar does not work on Linux platform.
Cant we create a flat file on Linux using the same code ?
Using the code I am able to create a file on Windows but the jar does not work on Linux platform.
Cant we create a flat file on Linux using the same code ?
Marshal
posted 4 years agoPlease explain more; we can only help if we know all the details. There should not be any difference between creating a file on Windows速 and on Linux; the PATHs have a different format, obviously. Tell us how you are trying to create such a file. Also find out whether the location you are trying to create it is accessible for writing or not.
Ranch Hand
posted 4 years agoRanch Hand
posted 4 years agohi, the jar does not work on Linux platform.
Does Linux machine configured properly to run simple java code/jar?
Thanks Campbell Ritchie for clarifying about Path.
Thanks Santosh Kumar Nayak for sharing small piece of code.
I write following code with the help of Google search:-
Might it helpful for newbies!
Millions saw the apple fall, but Newton asked why.
Ranch Hand
posted 4 years agoLinux machine is configured properly but the above code is not able to generate a *.txt file on Linux Box.
lowercase baba
posted 4 years agoare the permissions on the directory set to allow writing to the dir?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Marshal
posted 4 years ago/root/Desktop???
That is most unlikely to be accessible for writing. I suggest you change /root to a tilde and try writing it on your desktop ~/desktop/...
Please confirm whether it is desktop or Desktop; it matters on Linux.
That code needs a bit of editing. You don't need the two try blocks; apart from the names of the files they are identical. You should also close the writers in a finally (or use try‑with‑resources).
That is most unlikely to be accessible for writing. I suggest you change /root to a tilde and try writing it on your desktop ~/desktop/...
Please confirm whether it is desktop or Desktop; it matters on Linux.
That code needs a bit of editing. You don't need the two try blocks; apart from the names of the files they are identical. You should also close the writers in a finally (or use try‑with‑resources).
Saloon Keeper
posted 4 years agoI think the 'tilde' thing is a shell artifact and it won't work properly within Java program code. However there's a java.lang.System Property that returns the path of the current user's home directory. It can be used to construct an appropriate File object. Something similar to:
Note, by the way that that particular code works equally well regardless of whether it's running on Windows or on Linux.
Note, by the way that that particular code works equally well regardless of whether it's running on Windows or on Linux.
Being persecuted doesn't in any way prove your righteousness or your beliefs. Many people get persecuted because they are repugnant or annoying. Or just because they can be.