i have a Project and want to create a Launcher. But the Launcher i want to create is from a different FileSet as Default file set.
On Configuration i selected the FileSet i want to use
On "Configure Java invocation" i added the jar Archive as Class Path.
But if i want to select the Main Class it gives me the following Error
Empty class path
Why the Main Class is not detected. If i try it with the default file set it detects the Main Class
This is a bug, it will be fixed in 7.0.4. In the meantime, you can enter your main class manually into the text field.
Related
When creating new Java classes, my copy of Eclipse doesn't put them in a package. It gives me a warning about not putting the class in the default package, but it doesn't give me any other options.
I've seen other people use Eclipse, and their copy of Eclipse defaults them to a package named after the project they just created. I can't figure out why my copy of Eclipse is acting differently.
Here's what I'm doing:
File -> New -> Java Project
Name the project "quickTest". Leave everything else the same ("use default location" checked, JRE as JavaSE-16, Project Layout as "Create separate folders", Working sets unchecked, "Create module-info.java" checked). Press Finish.
Hit "Create" on the "Create module-info.java" popup, using the default module name "quickTest"
File -> New -> Class
In the "New Java Class" dialog, the package is blank and there's a warning about "The use of the default package is discouraged". If I hit "Browse...", "default package" is the only option.
What am I doing wrong? How can I get Eclipse to auto-create a "quicktest" package when it creates the project, in the way I've seen it do for other people?
Yes, I know I could manually create the package afterwards, but I'd rather not have to do an extra step.
This is Eclipse 2021-06 (4.20.0)
A new project does not have any packages defined. For the very first class you create in a project just type the package you want directly in the "Package" field of the New Class dialog. Eclipse will create the package folders and create the class in the package.
For subsequent classes you create the package will be filled in.
You can always type a package name in the Package field if you want to create a new package.
So, the owner of the other computer showed me the trick. Apparently, it matters how you start the new class wizard.
If you create a new class by right-clicking on the project in the Package Explorer, it will fill in the package name automatically. But if you create the new class from the File menu, it doesn't.
So, this works:
File -> New -> Project
Name the project "quickTest". Leave everything else the same (see above). Press Finish.
Hit "Create" on the "Create module-info.java" popup, using the default module name "quickTest"
Right click on the project name in Package Explorer -> New -> Class
The package name will be filled in with "quickTest".
(Apparently, this only works if the project name starts with a lower-case letter.)
Honestly, it feels like a bug that it works one way and not the other, but that's how you avoid needing to manually add a new package.
How do i create a 'FeatureFiles' folder within Eclipse > src/test/resources?
I can create a folder within src/test/java but how do i created the following folder listed below?
thanks
Create a new Package. Packages are equivalent to folders:
Right click src/test/resources, hover over the New tab and click Package. You will be prompted with a window containing a textfield in which you will enter the package name. If the name textfield is empty, then name the package "FeatureFiles"; if the name textfield is occupied, then add ".FeatureFiles" at the end.
If you want your resources folder to be separate as shown in your second image, then create it as a new Source Folder.
Also, it looks like are using an old version of Eclipse, consider upgrading to a newer version: https://www.eclipse.org/neon/
I have a jar file (not part of the Java standard library) that I want to use.
I've put myJavaPackage.jar into my project directory, and I'm trying to do import myJavaPackage, but I keep getting ImportError: No module named myJavaPackage. What am I doing wrong?
You need to make sure that Jython knows to search your .jar file for modules, which is done using pythonpath. This will differ depending on your setup, but in PyDev:
In the Package Explorer (the tree on the left), right-click on the project and go to Properties.
Select "PyDev - PYTHONPATH" on the left.
Click the "Add zip/jar/egg" button on the right.
Use the directory tree on the left to browse to the folder containing your jar, then click the checkbox next to the .jar file on the right, and click OK, then OK again.
You should also check that the module name you are trying to import matches the package name as specified within the jar file. Note that the jar file might be named differently to the package, especially if there are multiple packages within it.
If you have the source for the .jar, open up the .java file containing the code you wish to utilise, and look for a line near the top that specifies the package. If you find a line that says something like package foo.bar.myJavaPackage;, then you must do one of
import it like import foo.bar.myJavaPackage, and use the contents like obj = foo.bar.myJavaPackage.someClass, or
import it like from foo.bar import myJavaPackage, and use the contents like obj = myJavaPackage.someClass, or
import it like from foo.bar.myJavaPackage import someClass, and use it like obj = myClass, but careful of name collisions using this method.
I have two classes, Phone.class and Time.class. I would like to use their methods for my project in eclipse, but I cant figure out how to do it successfully. How do you import the .class files so that I can use their methods in eclipse?
Add the folder containing both classes to the build path for the project: right-click on the project in the Package Explorer window and select the Build Path option, then select the Configure Build Path option. The Libraries tab has Add Class Folder and Add External Class Folder options: use the first if the folder with the class files is already part of the project, otherwise use the second. Select the folder and then hit OK and you should be good to go.
When I try to add a new Classpath Variable in Eclipse for my Build Path configuration, and the path I add is a directory that the current workspace is a subdirectory of, Eclipse gives the error:
'C:\JavaStuff' is not a valid location for linked resources.
Why does Eclipse impose this restriction? I can't think of a good reason for it... I might want to put my JARs in C:\JavaStuff\libs and have my workspace in C:\JavaStuff\workspace, then reference libs (on my machine) via JAVASTUFF_DIR\libs where JAVASTUFF_DIR is C:\JavaStuff. This restriction prevents me doing this.
OK, the reason I was having this problem was not the Classpath Variable... it was the fact that I was trying to add it to the Java Build Path, because the way I was creating the variable was to go to the Java Build Path and click 'Add Variable'. After creating the variable pointing to the directory above my workspace, I OK'd out of that dialog and it tried to add that parent dir to my build path.
Looks like the way Eclipse wants you do add JARs via Classpath Variables is 'Add Variable', select the variable representing your base path, OK back up to the Java Build Path window, then edit the entry that's been added and manually add the rest of the path on (ie. turn MY_BASE_DIR to MY_BASE_DIR/libs/library.jar. A little bit unintuative.