How do you include .java files and .html files in a .jar file when you take Clean and Build in Netbeans 7? - jar

If you have files in the build/classes/folderToJar Netbeans7 takes the .class files and make a .jar file when you take Clean and Build.
But how can you have .java files and .html files go into the .jarfile as well?

First Create a package(Say html) under Source Packages
copy all of your html files to this package(when you create a package,a folder in the name of your package will be created inside your project src folder, so copy files to it)
You can access your html file from your program as
URL someURL = yourclass.class.getResource("/html/yourhtml.html");

Related

Can js file be compiled in a different folder from the source folder?

I'm building an Obsidian plugin, and it uses esbuild to bundle ts file to js file. The ts file is located at D:\foo1\foo2\..., and I want the js file to be at D:\bar1\bar2\.... The reason for this is because I want the source folder is in a different folder than the plugin folder, so that when syncing it to mobile I don't have to exclude the source files.
I was suggested to edit the esbuild.config.mjs file, and I find in the documentation that beside the outfile config there are also outdir, outbase. However, these are the results when I'm using them:
outdir
outdir: 'D:\Quả Cầu\B Nội dung\Knowledge graphs\Cây vấn đề\.obsidian\plugins\dotmaker'
error: Failed to create output directory: mkdir D:\GitHub\Obsidian\dotmaker\D:Quả CầuB Nội dungKnowledge graphsCây vấn đề.obsidianpluginsdotmaker: The directory name is invalid.
outbase
outbase: 'D:\Quả Cầu\B Nội dung\Knowledge graphs\Cây vấn đề\.obsidian\plugins\dotmaker',
It prints the js content in the terminal, but the real file isn't changed.
It seems that I can only create the js file inside the source folder. Is that possible?
You didn't correctly format the content of the outdir setting. When using backslashes \ as path separator on windows, you have to escape them. Ie use
outdir: 'D:\\Quả Cầu\\B Nội dung\\Knowledge graphs\\Cây vấn đề\\.obsidian\\plugins\\dotmaker'

How to put files in a folder and generate .zip file?

I want to generate a .zip file which contains some files and folders. The file inside the folder might be contained in some other paths and I want to put files in another folder and generate a .zip file from them.
By other words, I don't want to physically generate the folder with files. The files might be on some roots and I want to generate folder virtually to put them on the .zip file.
Imports System.IO.Compression
ZipFile.CreateFromDirectory("source","destination.zip",CompressionLevel.Optimal,False)
As an example if I have these files on my website:
- ~/files/image/1.jpg
- ~/files/pdf/2.pdf
- ~/intro.docx
I want to put them on a zip which when I extract it, the files will be as follows:
- ~/files/1.jpg
- ~/files/2.pdf
- ~/intro.docx
For the source put the root folder and it will do it
example :
This is yours
- ~/files/image/1.jpg
- ~/files/pdf/2.pdf
- ~/intro.docx
But before this there is a root folder whic is the ~ just simpily put as a source

how to compile a java file which is in a jar and then re-create the jar

I have a jar file (Gestp.jar) . And I have some .Java files (which are web applications) within the jar file
I need to modify a particular .Java file . And then re-create the Jar file and deploy it in a server.
I have extracted the jar file , and did the modification to the .Java file. But unable to create the .class file with the changes , in eclipse as it is a web application.
Please help.
Thanks in advance,
Aditya.T

Compress a folder with all subfolders into a .jar file

I have a directory of files with sub-folders and I want to compress it all in a jar file.
Later on , I need to use it in my project and add this jar file into my library section at eclipse.
Right click on a blank area in explorer window, go to New > Compressed (zipped) Folder. Drop whatever you want into it, and then rename the extension to *.jar.
source

How do I create a jar file, which includes xml and html files?

I am trying to create a jar file which includes some class and java files needed, but I also would like to include some extra xml, xsl, html, txt (README) files.
I am using Eclipse on Windows XP.
Is there an easy way for me to set up a directory structure and package all my files into a jar?
Add the files to a source folder and they can be included in the jar.
One common way is to have, at the root of your project, a src folder. Within that, folders for java files, and others. something like:
src/
css/
java/
html/
images/
Then you can make each of those subfolders a source folder (Right click, Use as Source Folder) and they should be available to add to the jar.
A .jar is nothing but a ZIP archive, so you can use any program capable of creating ZIPs. Just make sure that you include the manifest and all the class files.
I just added all the files into my Eclipse project (including the txt, html, xml, etc files).
Then I used Eclipse to File->Export->Jar File->Next
Check the "Export Java source files and resources" box.
Done.
If you're using Ant, you can use the jar task (see the examples section for how to include/exclude certain files, etc.)
If you move to an ANT (or Maven, for you Maven fans) then you can automate the Jar building very nicely, and also use it outside of Eclipse (e.g., in an automated build environment). All you need to do is copy the files from your src, jsp, foobar and resources locations into a build staging folder, then Jar the resulting files using ANT's Jar task.
<target name="makejar" depends="compile, copyfiles">
<jar destfile="${jars.dir}/myjarfile.jar" index="true" basedir="${build.dir}" />
</target>
One thing I look down on is including non-source (except package.html files for Javadoc) within the src folder. If you feel you have to do this to achieve something, then you are doing it wrong.

Resources