Java source code management with different IDE - java

Is it necessary to use the same ide to program in java? For example, I use IntelliJ to build a small java project about 2000 lines. Then the marker uses Eclipse IDE to mark this project. Does he need to import all the source code into a new project and set up everything for it? I didn't use any add-on on this IDE.
The reason I asked this question because I receive huge grade duction for using different IDE, the prof response me and said marker need rebuild everything for using different ide.
I drag my source code into Eclipse, and it works very well, so I am confused am I right or wrong?

Related

How I run individual java file in IDEA?

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.

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.

About changes which are not reflected back in netbeans

I have a java source code of a project developed on netbeans IDE-8.0 and edited its GUI on netbeans.
After this i switched to eclipse IDE (kepler) and modified several files to implement some logic.
After implementing this logic i want to change GUI again but at this time netbeans is not showing the GUI changes in design view (but code is updated as changed is eclipse) which are made using the same IDE (before implementing the logic in eclipse).
I have tried several options like
cleaning and rebuilding.
coping the modified source code to another work space.
Also window builder in eclipse is not able to parse the GUI java file.
Any reply for any IDE will be appreciated.

Eclipse not creating new .java file in New Project wizard?

OK, I have a really basic (read stupid) question. I am just beginning Java programming, and am using Eclipse 3.7.2. I have done a few beginning projects without any problems. All of a sudden, when I create a new project using the wizard, it is not creating the src/.java file. When I try to manually add it after creating the project, I end up getting some cryptic error messages.
I have re-followed several walk-throughs on project creation for clues as to any option I may have accidentally un-checked and no luck.
Googling the answer brings up results for more advanced problems that are unrelated.
I have combed the preferences, but nothing looks obvious, and
I have gone hunting for any user app data I could delete to force a clean slate.
I have even created a new instance of Eclipse to a different directory and still have the same result.
My son's instance, which is on the same computer still creates the .java file from the wizard. The only difference is that my instances have the Android SDK installed (I am trying to create basic Java projects and not Android projects).
I am at a loss, and have lost a lot of time trying to correct the situation. What do I need to do to reenable the creation of a src/.java file in Eclipse?
Screenshots (click on image for full size):
Make sure you are choosing a java project from the right folder in the wizard. It sounds like it is creating an android java project, which is probably why your src folder is missing. See if there is a helloworld project under example projects too in the wizard, that may get you started too. Screenshot may help us. I want to see which project type you choose and which folder it is in.
How about changing eclipse to point to a new workspace. That may drop the android settings. Under the file menu, choose switch workspace and pick a new location. Thats most likely why a new install did not fix it. That workspace may have android settings in it, so change to a new folder somewhere else to test it like c:\workspace2\
Here's a good tutorial I found that may help too.
eclipse java project tutorial

SVN and getting started with Eclipse Helios

I have been working as a programmer for approx 15 years. I have significant experience with 3 languages. Object Pascal, C# and Python. I just took a job (like two days ago) as a project manager for a Java project that has been written with the following tech stack.
Java EE
Eclipse Helios
Tomcat
Spring
MySQL
Code is in SVN
In preperation of starting the job, I read a couple of books on Java and played around with eclipse. The language doesn't bother me at all - it's very similar to C#. What I'm really struggling with now feels more like how to get started.
I've sync'd the code from the SVN repository, but literally am not sure how to proceed. I think I'm use to having solution or a project file to "open" (like in Delphi and Visual Studio). So, do I need to create a new workspace and "import" it from the file system?
I apologies for the newbie questions. I just feel a bit lost getting started here. Maybe someone that has recently come from a Visual Studio background can sympathize with me situation! :)
Thanks in advance for your help.
Well, it depends a bit on how your company's SVN is organized. For example, do they check in the Eclipse project settings, or do they expect you to check out the code and then generate Eclipse settings? Both are common approaches.
Assuming they have project settings in SVN, you should be able to just import them. You can either directly import from SVN as a new project (using the Eclipse new project wizard), or you can check out the code from SVN with an external tool (e.g. Tortoise) and then use Eclipse's import wizard to import the project. Go to Import -> General -> Existing projects into workspace, then browse to the location of your SVN working copy, and it should automatically pick up the Eclipse project(s) there.
update following up on your comments, let me expand a bit. Say, you check out a working copy from SVN using Tortoise, for example to c:\foo. You can then import any projects in that working copy into Eclipe, using the "Import existing projects into workspace" option I mentioned above. In the import wizard, you can choose if Eclipse should copy the actual code into its workspace directory, or should leave it where it is and just keep references. This is personal taste but I usually do not let Eclipse copy the code into its own workspace. That way, I can work with the code in Eclipse (and do SVN updates/commits directly from Eclipse), but also can quite easily do operations on my svn working copy outside Eclipse.
A workspace in Eclipse can contain multiple Projects.
When you open eclipse it has you select which workspace to use, and then you should be able to import the code into eclipse as a new Project. Have you tried using the Project Wizard?
You won't find an exact equivalent of the .csproj file, the closest you get is the .project & .classpath files, between them eclipse has all the information to describe a project. If your svn checkout contains the .project file, you can directly import your project into eclipse using the Import Wizard. Else you can try creating a new project and pointing it to your svn checkout.

Categories

Resources