I have saved a custom perspective in one of my projects and now I want to use that same again in my other java project but upon looking for perspectives category, my custom perspective is not showing up in the new project but is visible in the previous project.
I want my perspective to applied on all java projects which I ever I open automatically.
Is there any way we can export our perspective to a file format (like XML or something which eclipse can read on importing it again) and upon working on new project we can simply import them using the export file.
I don't know any solution to it but I have attached images for your references:
Java CP 2 is my custom perspective but it is not visible in another project.
How can I do something so that it is visible globally (in my IDE) and at present, I have to manually set up a perspective for each project I open.
Screenshot 1 - Java CP 2 Perspective
Screenshot 2 - Java CP 2 Perspective is not present
Related
So I'm trying to add jar files to a java project.
I've been told the following:
If you want a more beginner-friendly way of adding libraries, you can
also use the Project Manager for Java extension, which is included in
the Java Extension Pack. With it, you can click the + icon on
Referenced Libraries in the JAVA PROJECTS view, as shown in this
example. A quick tip if you need to add many libraries from a folder
is to Shift or Alt + click the + icon, which will let you select an
entire folder containing multiple .jar files.
After installing Project manager extension and creating a new Java project in VS code, I get to this screen.
As mentioned by VS code, I should be able to see the project view tab after creating my java project. The issue is I don't see the project view tab as shown in the image above. VS code says I should see the 3 dots by the explorer subheading to enable it, but again, I don't have these 3 dots as shown in the first image.
I have both project manager and the extension pack installed, so I really don't understand why I cant see or enable project view.
Any suggestions on enabling project view?
Have you tried to open a java file? Because the extension activated depends on the opened filename extension.
You can refer to here.
If it still does not work, could you provide the OS and the versions of the
VSCode and extensions?
I have struggled quite a bit with this and none of the 'obvious' solutions worked.
The way I ended up solving the issue is by creating a new Java Project and looking at the difference in the config of the files.
Especially in the .project file, there were missing entries. Some also in the .settings/*.prefs files
After updating those in my own project, it got detected properly.
As for the 3 dots, here's what I think: different versions may be slightly different, you see, there are no three points in this one enter image description here. So you may update it when you are free.
As for the project view, you may have to open a project before it appears, Steven-MSFT has said it in detail, you can see it first. If you still have questions, you can provide some details again.
Anyway, you can try the following 2 steps:
open a .java file
reboot your vscode
I am a java beginner, the first java IDE I downloaded was Visual Studio Code, it was very easy to use and everything is auto configured. But it kind overheats my laptop all the time, so I want to try IDEA, so far it's a very good experience, except when I open a java file and tried to run it in IDEA, it always pops out this run configuration window and I don't understand how to configure it. In visual Studio Code I can open any java file any time and run without any issues, but now I have to go through creating projects every time. Is there any solution for this?
From how the file icon looks:
your file is not recognized as the part of the sources of your project. Check the project settings to ensure that source directories are correctly set.
I'd also recommend you to look up and follow the conventions for the directory structure of java projects.
Once you've fixed the problem with sources, you'll see "run" icon next to your class, main method, or when you're right clicking the file.
Command-line
To run a single file, there is no need for an IDE.
In Java 11 and later, the java tool at the command-line can both compile and execute a single-file Java class. See JEP 330: Launch Single-File Source-Code Programs.
If your class named HelloWorld were in a file named HelloWorld.java, on a console type:
java HelloWorld.java
To be clear: The java command-line tool really only executes Java apps, while the javac command-line tool compiles Java source code. As a convenience, the java tool was enhanced to effectively call javac on your behalf for a single-file.
JShell
If you just want to run a few lines of Java, try JShell, the REPL tool bundled with Java 9 and later.
See:
Java Shell User’s Guide by Oracle
JEP 222: jshell: The Java Shell (Read-Eval-Print Loop)
Search to learn more and find tutorials.
BlueJ
Using an IDE such as IntelliJ, NetBeans, or Eclipse can be a daunting task for the new student of Java. Those IDEs are heavy-duty tools designed for professional programmers.
I recommend using an IDE designed for beginners. BlueJ comes to mind, designed specifically for educational purposes. BlueJ makes getting started with Java easier.
If you insist on using IntelliJ, read on.
If using IntelliJ, define a project
IntelliJ is not designed to work with single files. IntelliJ expects you to work within a project.
I strongly recommend learning the basics of Maven to create and drive your new project. By defining your project in Maven, the configuration is independent of any one IDE. You can move your project between major IDEs such as IntelliJ, NetBeans, and Eclipse.
Maven is also very useful for downloading needed libraries ("dependencies") that you may want to leverage in your work. And Maven is good at packaging your Java app as a JAR (or WAR or EAR).
In IntelliJ, choose "New Project". In the New Project window, click the Maven item on left. Check the Create from archetype box. Scroll the list to find item for org.apache.maven.archetypes:maven-archetype-quickstart. Under that, choose the "RELEASE" item. Click Next button.
In Name field, enter something like MyFirstProject. Click Next button.
On the Maven settings page, just click Finish.
Wait a moment for IntelliJ to download some stuff and configure your project. Eventually you should see a BUILD SUCCESS message in the Run pane.
You will also see a pom.xml file displayed. The POM contains your settings for Maven to run your project, in XML format.
Change the <maven.compiler.source> and <maven.compiler.target> elements to the version of Java you are using. The current version is Java 17.
After editing the pom.xml, look for a little floating windoid with a tiny Maven icon. Click the icon to have Maven process your changed POM. Wait a moment.
In the Project pane, navigate to the App file. There you see code to print “Hello World!”. Let's run that code now. Click the green triangle button on the left, in the gutter, next to the main method line. A pop-up menu appears offering a Run item. Choose that item to run the app immediately.
Down in the Run pane, you should see the results, the Hello World! text.
At this point you can add your single file to the org.example package seen in the Project pane.
By the way, you can change that package name by context-clicking and choosing Refactor > Rename….
Later, learn to use the Run/debug configurations feature of IntelliJ.
Know that you need not create a new project for each time you want to do a little experiment. Create one project for such experiments. Keep adding new .java class files for each experiment. Delete old class files you no longer need.
Eventually, I suggest updating the versions of various items in your POM. The QuickStart archetype is not configured for the latest versions (for reasons I cannot fathom).
And when you learn about unit testing, replace JUnit 4 in the POM with JUnit Jupiter (Aggregator) to use JUnit 5. One of the benefits of using Maven is that you can easily switch out dependencies such as going from JUnit 4 to JUnit 5.
The IDE needs to know what's called the entry point of the program, i.e. where to start running your code. That's what the "Edit Configuration" window is wanting you to do.
If your file "Lab3.java" is in a package, make sure to fully specify that in the field you have in red. Otherwise without knowing how your project is structured (as the other answer alludes to), it's difficult to pinpoint what we're missing here.
When you create your IntelliJ project, add a directory /src right at the root of your project. Right click on that folder and tell IntelliJ that you wish to mark it as a source root. The directory should turn blue in color.
Put your packages under /src. IntelliJ will know that those are Java files.
When you want to run a class with a main method, choose Run->Edit Configurations. Tell IntelliJ that you want to add an Application. It should prompt you with the classes that have main methods in them. You'll have no trouble running them.
Use Maven or Graddle. Make sure the project is configured with the build tool enabled and integrated, it will do basic things automatically. If you are not sure, please create a new project and add your files in. Steps:
Open the IDE
New Project
Choose from the left side bar "Maven" or "Graddle"
Give it a name and the location in your machine.
Click Finish
Now you have the project ready. You need the appropriate method to run in java. A main class. In IntelliJ you can just type "main" and the auto-complete will add it for you, make sure you inside the curly brackets of the class {}. More info about the main class. You seem to have this nailed down.
Lastly make sure you have a JDK installed in the IDE. I am pretty sure this is your issue here, make sure to use one of the option IntelliJ provides. A full guide from the developers is here and should satisfy your needs. I would suggest OpenJDK for a beginner, because that served me well at the beginning, at the end of the day its your choice.
Previously I used Eclipse, but now I am using Intellij IDEA. But I can't understand one thing. In Eclipse I have SETs in which I have a group of projects. At all I have a lot of different small projects to which I have simultaneous access and I see them all in the Package Explorer. In Intellij IDEA I see only one project, and this is not convenient for me.
Does Intellij IDEA have an analogue Package Explorer? How can I see many projects in one window?
I believe you cannot open multiple unrelated projects in one window like you do in Eclipse.
You'd need to open them in multiple windows, File > Open ... and you'll choose a new window. I also wished Intellij could open multiple projects in single window. But now I get used to it. Just click CMD + ` to switch between Intellij instances on OSX.
If they're modules of your project, then you can add them from File > New > Module From Existing sources...
I'm working with Ligdx, an API for cross plattaform game development that by default generates at least 2 projects:
The core project: This is the one you are supposed to work on, where all the classes and logic should be placed.
The desktop project: This one is automatically generated from the core project.
The core doesn't have any class to start it because it's supposed to be started from the desktop (or other platforms) project.
It is also always selected -because its what you are working on- so pressing the "run" or "debug" buttons will attempt to run the core project and not the desktop one and immediately fail thus forcing you to select the desktop project before hitting run/debug. This can get extremely annoying, especially when debugging.
So is there a way to force Eclipse to always run the desktop project?
Rekaszeru's answer to this question shows how to set up Eclipse in order to always launch the previously launched application.
You simply have to go to preferences / run-debug / launching and check the "Always launch previously launched application" box as he shown in the picture he used to illustrate his answer:
This will not force one of the projects to always be launched but it would pretty much solve the problem unless you are working on multiple projects at the same time or you alternate between Web/Android/Desktop.
If Your asking how to start a Core project from already existing project present in the eclipse then all you need to do is Right Click on desktop folder of the project and go over Run As and select Java Application
But if that is not what you have posted for I can only understand that you need to understand how a LibGDX project is deployed.... From Desktop project "In xyzMain.java" file you will have a method call to the core project saying:
new LwjglApplication(new Sample(), cfg);
This is where you'r Sample Class from the core project is called over.
But from the title I get a diff feeling that you wish to add another project to your already existing project...
You can do that by changing the build Path of the project....by including Other proj to the one you wish to compile and run.
Hope this helped you out..
I´m not aware of doing exactly what you have described, but I´d suggest using the Launch Configurations menus and dialgos to do what you want in a similar quick way.
Note that you can configure your launch configurations doing: Run -> Run Configurations... (also Run -> Debug configurations...)
Option 1).
Once you have run your Desktop Project, simply use the Run Drop-down button, which contain your launch configurations:
Option 2).
Save a launch configuration file in your Core project (or wherever you want) using the last "common" tab of the launch configuration dialog:
Then you can simply right-click on your that file to launch your Desktop Project:
P.S: I´d also suggest reading a little bit about run configurations in lars tutorial
I'd like to know if it's possible to have several instances of Eclipse open at the same time. I'm using it for Java development. I know I can have several files from different projects open at the same time (at least that's what it seems to me), but whenever I try to open a second instance it shows me the following message:
alt text http://img46.imageshack.us/img46/5033/sxbz3mti34afybrafhc32m0.png
Is there any easy way to have several instances of Eclipse open, each one with a different project?
Thanks
Either create multiple workspaces (Preferences / Startup, tickbox to ask which on every startup)
Or more likely, I think Window / New Window will open a second eclipse viewing window on the same workspace.
yes, each on a different wokspace.
Projects and Workspaces in Eclipse are different. A workspace has a set of global settings and then it has a set of projects.
There are two kinds of project. Projects in the workspace and projects outside the workspace. If you use in the workspace projects (for example, by telling eclipse to make a project via a source control checkout), then it can only be in that workspace.
If you create projects outside the workspace, then you can import each one into as many workspaces as you like.
You can make as many workspaces as you like. Each workspace can be open in only one instance of eclipse.
A better answer to have only the resources from certain project in the new Window is by right clicking the project and select "Open in New Window"
You may want to use Working sets.
A common problem in Eclipse is that
your data in your workspace grows and
therefore your workspace is not well
structured anymore. You can use
working sets to organize your
displayed projects / data. To setup
your working set select in the Package
Explorer -> Show -> Working Sets.
I tend to use different workspaces for different contexts, not just working sets. For that none of the answers above is satisfactory, instead you might want to use the "-data" option on the command line. That allows you to specify the workspace to open, if that is different from the already open one, then a new Eclipse instance will be started.
See http://labs.distriqt.com/post/844 for more details.
There is a way. I have several installations of eclipse in separate folders. Each setup for a different language/job and perspective (CF, Java, Birt). Each has its own workspace so they don't interfere with each other. You can work out if your machine can handle the multiple instances.
If I understand well, your problem is that you would like not to see the other projects while working on one. What you could do is close the projects you're not working on, and then in the package explorer, choose filters > closed projects. This way the closed projects no longer appear in the package explorer.
If you want multiple Eclipse instances open on the same workspace (with the same projects) then you want to use 'Window > New Window'. This will even let you drag views from one window to another.
If you want to display different sets of projects in each Eclipse Window then I'd suggest you use set up a 'Working Set' for each combination of projects you want to work with. You can then select a specific working set from within the Package Explorer. You can create working sets using 'File > New > Java Working Set'.
Something else to consider is that a Workspace is more than just a group of projects - preferences are all stored at the Workspace level. This means that it is quite easy for your preferences to get out of sync if you work with multiple Workspaces.