1

So I have a project with just one java file

Main.java

My workspace is located at /programming/workspace

I added external jar's to the project to use the apache poi. I can run my program through eclipse and it works just fine but I need to be able to give this program to my friend and be able to run it through the terminal.

I was trying to do Java main where the Main.class file is located but got:

     Exception in thread "main" java.lang.NoClassDefFoundError: Main
     Caused by: java.lang.ClassNotFoundException: Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

How do I get my program to run through a command line that I can give to someone else to run it?

2 Answers2

1

Via Eclipse - > Export - > Runnable jar file -> Set the class which has a main method and you want to run when called in the terminal - > Finish (be aware to include the external .jar)

Ioan
  • 5,152
  • 3
  • 31
  • 50
0

select the project. Choose export, export as runnable JAR file

bvanvelsen - ACA Group
  • 1,741
  • 1
  • 14
  • 25