I have a NetBeans Java project which run fine on NetBeans. The application has several classes, reads from several files to take input and also uses Jackson jar library. Now, how to run this project from command line properly so that it gets required library and files it needs?
Asked
Active
Viewed 1,122 times
3
-
1Do you use any build tool like ant,mave or gradle? – erhun Apr 25 '15 at 08:58
-
No. Should I? @erhun – anik_s Apr 25 '15 at 09:00
-
Is it standalone application or web application or other?? – Viraj Nalawade Apr 25 '15 at 09:00
-
It's just a simple Standalone Java Apllication. @VirajNalawade – anik_s Apr 25 '15 at 09:02
-
4if you are you can easily build, compile and run it. for maven just mvn clean build install command can be enough to prepare the final jar, then you can run the jar java -jar blabla.jar – erhun Apr 25 '15 at 09:06
-
I can have a jar of the application by building it on NetBeans. But somehow it throws exception. I have a code like 'InputStream input = new FileInputStream("book-info-converter.properties");' Does it create problems with jars? @erhun – anik_s Apr 25 '15 at 09:10
-
*"Does it create problems with jars?"* - That depends, where is the `"book-info-converter.properties`" file stored in relationship to the program? – MadProgrammer Apr 25 '15 at 09:13
-
The file is in the root directory of the NetBeans project. Where should I put this file or any jar library that are required for the program? @MadProgrammer – anik_s Apr 25 '15 at 09:16
-
1Library/dependent Jar files will be place in the `lib` directory within the `dist` directory (assuming you're using Ant and not Maven). The properties files should be placed in the same directory as the resulting jar file (ie the one in the `dist` directory). You should copy the contents `dist` directory as a whole (you can rename the `dist` directory, but in order to run correctly, you will need to keep the contents in the same structure). You could modify the build process to copy the files you require into the `dist` directory, but that becomes another question – MadProgrammer Apr 25 '15 at 09:29
-
Use `java filename` as stated in [this post](https://stackoverflow.com/a/16137745/6532488) – Yk Poh Sep 24 '17 at 10:44
1 Answers
0
Netbeans uses Apache Ant for building. Install Ant then execute in terminal, under project folder:
ant run

tiboo
- 8,213
- 6
- 33
- 43