Create a new Java project
- File>New>Java Project
After the Java project is created
- Right click on the new created folder by the Java
- New>Package
- Now add the new Java Package name.
- You can use dots (.) to specify multiple folders.
- After the package is added you will see a Tree Hierarchy of the folders which you can see when you go to the folder or when you add the class file inside it.
To add the class file
- Right click on the last folder and click NEW> Class
- This will create the new class for the project.
Running you Java program outside Eclipse(create a jar File)
- To run your Java program outside of Eclipse you need to export it as a jar file. Select your project, right click on it and select "Export".
- Select JAR file, select next. Select your project and maintain the export destination and a name for the jar file. I named it "myprogram.jar".
Adding external library (.jar) to the java classpath
- From the menu select File > Import > File system. Select your jar and select the folder lib as target.
- Select your project, right mouse click and select properties. Under libraries select "Add JARs".
- If you find some errors in the import then find the jar in eclipse/plugin folder for the missing jar files.
To change the JRE you are currently working on
- Window > Preferences > Java >Installed JREs
- Add the new installed JRE. Check the one you want to use.
- Now go to
- Window > Preferences > Java > Compiler
- change the "Compiler compliance level" to the one you are using
To fix the JRE not compatible with workspace .class file compatibility: 1.6 error
- Window > Preferences > Java > Compiler and change the "Compiler compliance level" to 5.0
REFERENCE:
No comments:
Post a Comment