Package gets distributed while importing a project into Eclipse - java

I am trying to import a GUI project into my eclipse kepler on my Windows server 2012. After importing the package explorer looks like:
mygui.applet
mygui.swing.main
mygui.swing.main.dialogs
mygui.swing.main.events
Where as it should look like:
-mygui
-mygui.applet
-mygui.swing
Where my gui.swing is the parent package containing dialogs and events.
I tried importing the same project into another eclipse installed on a Windows 8 machine and it gets imported correctly.
Is this a problem of using eclipse on windows server 2012? Are there any pre-requisites I need to be aware of? Which other alternate Java builder can I use alternately on a virtual machine for a project of big size?
The method I am using to import my project is:
Create Java Project-> Import File System->Select Folder (This works on windows 8).

There is nothing wrong with your project. It's a preference in Eclipse. In the top right corner of the Package Explorer view is a downward-pointing triangle which opens up a drop down menu with an option called "Package Presentation" - this opens up a sub menu with the choices of "Flat" or "Hierarchical". You have "Flat" selected and need only to change to "Hierarchical" for the effect you desire.

Related

Exporting and importing java project in Eclipse from Windows to Linux

I'm trying to migrate my java project from my windows machine to my linux machine. I'm using Eclipse's import/export function.
This is how the structure looks like on windows:
but when I import on the linux side the structure is completely different... and it doesn't work.
I also tried moving the files/folders directly into the workpath. That kept the structure in place, but when trying to run the files, I only got an "does not contain a main type" error.
Exporting/Importing from windows -> windows works just fine.
Any Ideas why this happens?
I solved the problem now. For some reason the Java version was set to 1.4 in the .project file... don't ask me why. That was the source of the errors in basically every file since this version doesn't support things like the diamond operator and annotations.
To do this I went into
Project -> Properties -> Java Compiler -> untick "Enable project specific settings"
Probably one of the more unusual issues I had so far and I have no clue why something like this would be set as default. On a positive note the structure created by the import function was not the issue at all.
The differences you are seeing in the view structure is that you are using a different view on Linux and Windows. On Linux it looks like you are using the standard Java view called Package Explorer that collapses packages and puts nice icons for "source" folders. The Windows screenshot looks like a Navigator View. Unfortunately is it hard to be sure as the screenshot does not show the view name.
Here is a screenshot showing both views side by side on my Linux computer for a simple project:

Eclipse: Imports not being recognized

I'm using in my Eclipse (Java EE edition) project some classes, like the ServletConfig, for example. If I just add some code with an object of this class without importing it, and click on the error sign (where should appear the import option), it only shows the option to create a class with that name. And if I import it anyway:
import javax.servlet.ServletConfig;
It points an error and shows me the option to create the class 'ServletConfig' in packgae 'javax.servler'. It was working on another computer with Windows 7. The one I'm using is Windows 8.1.
Help!
It sounds as if your project isn't configure as a web project but rather as a plain Java project. Usually, you would do it when you create a project. You'd select File / New / Dynamic Web Project.
If you haven't done so, you should be able the fix the configuration. In the project settings, go to Project Facets and check Dynamic Web Module.
If I'm not mistaken, you'll need to set up a web server runtime environment as well. First go to Eclipse's preferences and select Server / Runtime Environments. If the list is empty, add one.
Then go to the project settings again and make sure there is a targeted runtime selected:
If everything goes ok, the project explorer will show all the web server jars in Java Resources / Libraries / Apache Tomcat v7.0 (or whatever your environment is called). One of the jars is servlet-api.jar and contains the classes you're looking for.

How to up and run java code in JasersoftStudio?

I would like to know something if possible. As I used JaspersoftStudio, I noticed that when creating new project folder it always came up with JRE library. I also see java editor in there as well. Is it possible to write and run java code in JaspersoftStudio GUI?
Please share your ideas on here.
Regard,
Sakura
As you may have noticed, Jaspersoft Studio is a repackaged eclipse. And yes it is possible to run Java code in it, it's just a bit more cumbersome than in vanilla eclipse.
In any of your jasper projects (the project icon in the explorer should have a little J), right click and open Properties.
In Java Build Path, add a new source folder.
In your new folder, create a new File, and put your main class in it.
You can now run it with the keyboard shortcut Alt-Shift-x j. I don't know if there's a menu for that too.
Additionally if you have an existing eclipse project, you can import it directly into Jaspersoft Studio using Import... Existing Projects into Workspace.

How to organize jar files in a libraries folder in Eclipse?

I have a Java Project in Eclipse, and a Java Dynamic Web Project in Eclipse. In the former, all the jar files are shown individually under the top-level project folder. In the latter, the jar files are under a Libraries folder and the navigation is more convenient.
Is it possible to organize them in the same way in the Java Project also? If so, how?
Update: It is the Project Explorer View. For the Java Project, I see: "my_project_name" with the arrow expanded to point downwards, then I see: "package_icon src/main/java" and below that "package_icon src/main/resources" and then 20 jar files one below the other: "jar_icon activation-1.1.jar", ...
For the Java Dynamic Web Project I see: "my_project_name" as above, then I see: "JAX-WS Web Services" (unexpanded), then "Deployment Descriptor" (unexpanded), then "Java Resources" which I have expandeded, so I see the components of it below, of which the first is: "package_icon src/main/java", then below it, "package_icon src/main/resources", then below it "libraries_icon Libraries" instead of 20 jars! I have the option of expanding Libraries if I really need to see the 20 jars.
The only option I found to make things prettier in Eclipse Kepler is to:
In the Project Explorer window there is a down arrow in the upper right corner. Select that and then Customize View.
Select 'Libraries from external' and then OK.
Kind of cheesy...
EDIT: Of course I had to go and do some more digging...and it looks like I'll have to try this and see how it works.
Similar to M Miller's answer (but for Juno), click Show 'Referenced Libraries' Node in the dropdown of the Package Explorer window:
I'm using:
Eclipse IDE for Java Developers
Version: Juno Release
Build id: 20120614-1722
I noticed this "feature" on Eclipse Juno (latest version), when you have a jar file added to the build path it is not shown as a single file on the project.
Try removing one of the jars from the build path to see if it shows up again.
I couldn't find how to turn it off though.
BTW... the project layout for your "Java Project" is more akin to a "Maven Project", which is a bit more powerful.
You should change into the Package Explorer by Window > show View. It will display all the referenced libraries in a Referenced Libraries folder.

Problem in compiling java project in Netbeans

I have a problem now :
When I want to compile my project in Netbeans IDE I had this message error :
Problem: The project uses a class library called "toplink", but this class library was not found.
Solution: Click Resolve to open the Library Manager and create a new class library called "toplink".
In fact I didn't change anything and it works fine before?
What's the problem?
It seems that you have to import the library itself.
On the left pane in your Netbeans editor, you should have a series of panes. One of these is called the Projects pane. If you click on it, you should be able to see the files and packages which make up the project you are editing as nodes. One of these nodes, at the very end is called "Libraries". Right click on this node and select "Add Library". From there, you should be able to browse and locate the library.
I believe libraries are defined for the NetBeans installation rather than for the project. You can import a library into a project which would make it available on other NetBeans installations. Perhaps you are on a different computer or a new installation of NetBeans?

Categories

Resources