Steps to create a sample project in Eclipse and execute in command line;
- Create Eclipse project and compile it. It will create output in bin folder, which will have .class files.
- Create a batch file for classpath. In this batch file create set classpaths for all jar files which are used in Eclipse project. Also set classpath to bin folder of eclipse project.
- Copy all the required resources in bin folder. In my example, I had to copy "WcmApiConfig.properties" file in bin folder.
- Now you can execute Main class using Java Main Class.
- See sample batch file for setting classpath and executing the file.
Sample batch file for ClassPath
SET BaseFolder=C:\Users\Administrator\workspace\MyLearning01\
Set CLASSPATH=%CLASSPATH%;%BaseFolder%bin\;
Set CLASSPATH=%CLASSPATH%;%BaseFolder%lib\MyFirstJar.jar;
Set CLASSPATH=%CLASSPATH%;%BaseFolder%lib\MySecondjar.jar;
Sample batch file for the main class:
java eshu.learning01.MyMainClass
No comments:
Post a Comment