How to import/open existing .java files in IntelliJ? - java

I'm still new to IntelliJ and still learning how to use it. Basically I have created a program already before and I just want to use my existing .java files in IntelliJ. I tried import/open option on the intro screen of IntelliJ but when I opened the .java files there weren't any menus, no functions, and you can't run the program at all, it just seemed to open a tabbed text editor of my .java files. So I tried creating a new project, and then opening the .java files afterwards, but no dice too, the run button is blacked out and I can't run my program. I used the command prompt before and used java (filename.java) to run my program and now just migrating to use an IDE. Can somebody help? I seem to have stuck at the beginning of my IDE journey.

You cannot simply open a file using Java. IntelliJ IDEA needs several configuration like Java SDK and other configuration files in order to run it. You have to create a simple Java project and copy your already created Java file into that project's src directory. Then you will be fine.

I just opened the first folder with '...web' as part of its name :) Not sure how scientific that was.
I am using Jet Brains Itellij Idea version with this info:
IntelliJ IDEA 2021.2.3 (Community Edition)
Build #IC-212.5457.46, built on October 12, 2021
Runtime version: 11.0.12+7-b1504.40 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 1972M
Cores: 4
Kotlin: 212-1.5.10-release-IJ5457.46
I drilled to a folder called detourweb. The app found what it needed.
Again, not sure how scientific or repeatable this method is. Assuming all developers will have some 'web' file in their project, try rolling the dice and drill to the first such file.
I don't expect a lot of up votes here, LOL. Here's an answer from a .Net Visual Studio dude.

Related

Vs Code java The import cannot be resolved

I recently moved from windows 10 to Ubuntu 16.04, I'm a java developer, when I was on windows I installed Vs Code with the java Extension pack. On windows I never Had problem to make my daily work, but on ubuntu, every java file is marked as error, with the message "The import cannot be resolved", searching a litle bit, i found that you can execute the command java:clean the java language server workspace, but this does not fix the problem. I also remove the tmp files from the workspace located on:
~/.config/Code/User/workspaceStorage
the current Version of Vs code is 1.41.1
the current version of Java Extension Pack is 0.8.1
Any ideas?.
Regards!.
Edit:
all my java files are marked as error
inside of every java file
this is the result of the maven-install
well, after a while of searching, I found that the "maven for java" plugin was trying to download the maven plugin maven-metadata.xml, which wasn't available on my repo. this caused a conflict with the initial build that maven for java was doing. to avoid to update every time I opened vs code, I removed the option "update snapshots"
And the initial build was done.

Libgdx: Gdx.files.internal() points to wrong place on laptop, correct place on desktop?

In my Eclipse LibGDX project, it seems to think that the root directory is different between machines. For example, on my desktop, and the desktops of two other friends running the same version of Java and Eclipse with a git-cloned project, running File file = new File("/config") returns this path:
/core/assets/config
Running it with the same version of Eclipse, and the same Java version, and the same git-cloned project, on my laptop, produces the following:
/desktop/config
Clearly, there is something wrong here. Even the native LibGDX file-handlers are looking for the assets folder in /desktop/ instead of /core/, which is a problem since it completely breaks the otherwise functional code, rendering my laptop completely ineffective for development purposes.
What I have done:
Reinstalled Java on laptop
Reinstalled Eclipse, removed all user-preferences on laptop
Completely deleted directory containing git project
What can I try to resolve this?
If you want to see the structure of the project in question, please see here
Set the working directory to core/assets/ directory when running the application.

IntelliJ - How to run current program regardless of errors in unrelative files

I am start learning Scala, I am using
Java 7 and
IntelliJ IDEA 2016.1.4
Build #IC-145.2070, built on August 2, 2016
JRE: 1.8.0_77-b03 x86 JVM: Java HotSpot(TM) Server VM by Oracle Corporation
I got some sample code programs online and trying to run one by one.
But not working, while I try to run, it showing errors in other files but there is no relationship with them, all most all are independent Scala classes only.
IntelliJ Idea, run code regardless of errors in unrelated project files
I followed this similar issue, but I am not able to find options they suggested. like "Make before launch" and other might be very old post.
The option is still there, you just need to look for it in your run configuration window.
As you can see in the below GIF, when you create a run configuration it will implicitly run make before running, and initially it will fail.
The, you edit the run configuration and replace make with make, no error check. If you get a ClassNotFoundException when launching it right after, just re-run it again. I haven't figured out why this happens, it's probably related to how IJ cleans and compiles the classes in this particular case.

Issues with Eclipse while working on and Android project

I am currently developing an application with my software engineering classmates. I am experiencing a few issues with Eclipse, however. But first, some information about my Eclipse: I am running version: Juno Service Release 2 with a build id of 20130225-0426. I am running Eclipse on my MacBook with OS X Mountain Lion 10.7.5. I am using SVN to upload and download the project to a repository through assembla.com.
First, Eclipse will not recognize any errors. If I purposely type random characters, Eclipse does not underline them with red.
Next, whenever I type "this.whatever" or "# for javadoc" I receive the following message: "this compilation unit is not on the build path of a Java project." I can click "OK" and continue with no problem though.
Finally, whenever I attempt to run the program I receive this message:"The selection cannot be launched, and there are no recent launches."
Other notes: I do not have any of these issues with any of my other projects in my workspace. I also have another project using the assembla repository that does not contain these issues. These issues just occurred all of the sudden.
Edit: None of the other members in my group are experiencing these issues. I have attempted to download the project from the repository on a different machine and I still have these problems. I have attempted to delete the project from my workspace and re-download. Still a no go.
Update: I even installed the Android Development Kit and used the included copy of Eclipse. It will still not work properly.
What is going on with my Eclipse?
Since I guess you're in start phase of android coding and you're not addicted to a special IDE, I strongly recommend the IntelliJ IDEA instead of Eclipse for Android development. I have tried Eclipse already and because of its weaknesses, now I'm using IntelliJ. Eclipse is not the best IDE for Android development and have a long way to become the one.
IntelliJ IDEA
I suggest you try installing the ADT bundle in a new location and see if you still have these problems. The ADT bundle includes the latest Android SDK along with a version of Eclipse with the ADT (the Android Developer Tools plugin) already installed and configured. It's possible that you have (or have had in the past) other Eclipse plugins that affect how the Java tools in Eclipse work, possibly in a way that interferes with ADT. I have personally had problems like this in the past with tools like Aptana, where even after uninstalling there would be problems.
Eclipse is telling you already with the above error message: You don't have your sources on a build path, but just in some folder.
Either you have created a simple project instead of a Java project, which then also doesn't do anything Java specific. Or you have created your Java files in plain folders, instead of source folders.
The best way to sort this out is to create a new Java project using the Eclipse "New..." wizard from the main menu. Compare the result of that to your project. The two important things are: The project has an icon with a small "J" overlayed. The Java sources are shown in packages, which themself are in source folders (with a package overlay), not in simple folders.

Thinking in java library installation

Hi i've been trying to install the library on Thinking in Java book 4th edition and i hit a very thick brick wall. I've done everything that the guide from the website told me to do and i still can't get the library to work. From what i've read it seems that the problem is from the build.xml files. having no xml knowledge I am clueless about how I have to modify it in order for it to work. In both cmd and eclipse I am getting these error
c:\TIJ4\code\build.xml
Build Failed
c:\TIJ4\code\build.xml:59:J2SE5 required
Can anyone tell me what I should do ?
I am using eclipse if there is a simpler solution by using eclipse rather than ant please help me out. It's been a week now and I still can't make it work.
The important thing to do is to realize that your ant file has a specific java requirement.
Something to try that might fix this very easily : I believe you can remove any references to a specific JDK, and if you have a reasonably up to date JDK, the build will succeed.
The definete fix : Look into the exact (line 59) of your build file, and try to satisfy the java version that line requires. Java is generally backwords compatible -- something designed to run in J2SE5 should run in the latest JDK. Its not terribly difficult to update your JDK (just google for instructions on your OS).
The most common mistake I see is that people who have the java run time installed believe they also have the Java SDK as well.
Does this "install the library" means you want to look at the code and run them in your eclipse? If so I can share my experience with you.
First run the Eclipse.py script; this will add package info to the source code
Create a new Java project in Eclipse, and then just copy all the source code folders to the src source folder in eclipse, these folders will then be recognized as Java packages.
You should be able to run the classes with a main function.
You can also configure which java version to use for this project in Eclipse build path. 1.5 or higher will work.

Categories