I've checked out Eclipse and jEDit and I'm having trouble with both.
With Eclipse I can't seem to open a java file and edit it then compile it. I always have to make a new project and then copt and paste my code. It's frustrating and a time waster.
With jEdit when I open files I'v worked on on other computers I get random characters. I also can't figure out how to compile.
None of this happens when I use JCreator on my PC. Will you guys lend me a hand?
Eclipse is project-based. It won't just compile a file on the fly, the whole IDE is based around having projects and then adding files to the projects and then compiling and running the projects. I agree that if you only have one file you're playing around with, this is a bit inconvenient, but that's the way it is. FYI: Your Eclipse should also have an "autobuild" feature which will compile your project as changes are made so you don't need to compile before a run (which is also usually automatic). For small projects on a powerful machine, the performance hit is usually negligible.
In Eclipse you don't need to "COMPILE". Every time you save your Java program, you also compile it.
Just RUN the program you are writing from the Run menu.
Never worked with jEdit, so I can't help with that but it looks like you are having encoding problems.
I have been working on Mac OS X with Eclipse and it was a very good experience. You definitely don't need to create a new project every time you want to change & compile something.
Hope it helps.
Related
I want to change literally one word from a java project on github and compile it to .jar
I cloned the code using github desktop app and open it with visual studio code but there are 259 problems I don't know what.
enter image description here
I forced to compile it anyway, this is the result
enter image description here
Before there was a "JAVA_HOME is not in your enviroment", I googled it and added a new environment with C:\Program Files\Java\jdk1.8.0_221
I have contacted the developer but it seems like they get annoyed I'm asking questions. It is my first time compiling java to jar so please teach me kindly, thank you.
but there are 259 problems I don't know what.
Programs don't live in a vacuum. Specifically, this project uses open source libraries. That's common - just about every modern programming project does. Some ecosystems (such as node.js) elevate it to a competition and even the simplest app include thousands of one-liner open source libraries; java (the ecosystem/community), at least, isn't quite that frivolous with its libraries.
Building a project is, as a consequence, not quite as simple as 'just compile all the java files you can find in the repo'. The source code (the stuff you cloned) contains descriptors of libraries, such as org.apache.commons::commons-lang3::3.12.0 (literally that string or something quite similar to it in a file named pom.xml or build.gradle or build.xml or similar - a file that describes how to build, test, and run the project), and the build tool will then go ahead and download these libraries automatically from open source repositories.
That process gets you the libraries that this project is built on top of, such as org.apache.commons.cli. You didn't run this process, hence why your editor is telling you that it can't find org.apache.commons.cli.
I forced to compile it anyway, this is the result
That obviously doesn't work. An error is an error. Programming is a little harder than just doing your best Harry Potter impression and wishing it away. You'll need to fix this.
Figure out what build tool is used to build it, and use that to build it. Generally the project's readme will explain this. If not, if there is a file named build.gradle, it's gradle, if there's build.xml it is likely ant, and if there is a pom.xml, it's maven. These are all widely used open source tools with hundreds of tutorials on how to use them available. Read up, and get to building!
Only when you successfully build this app in vanilla form (fresh off the clone), should you then start on modifying things.
Recently I have been working on coding Minecraft mods. Yesterday i updated to a 64 bit version of Java, and I began to receive an error that said something of this nature: "Java returned error = 13". I looked around, and discovered that my Eclipse was not 64 bit, so I went to Eclipse, and downloaded the latest 64 bit version. I then replaced my normal eclipse folder with the new one, and it launched fine. However, when I open Eclipse, (I open the exact same workspace as I did before all of this happened), I don't see anything in the Package Explorer view. Nothing at all. Typically it says MDK Example or something like that, and within that are all of my packages, etc.
Here is my question: How can I make it to where I see all of my files in the package explorer like they used to? I am using the same Workspace...
Just a warning: I code a lot, and I believe that now I'm quite skilled at it, however I am not good with computers themselves (hence why I find myself in this predicament). If I need to completely start over, I can, and I can copy over my code. It would be a nuisance but if that is all that is left to do I will do so.
Thank you for reading! Please help if you can :)
I remember encountering a similar problem after having switched the location of my workspace.
Try the following: Choose a different location for your workspace and then choose File>Import>General>"Existing Projects into Workspace".
I have this problem with both Netbeans 8.0 and Eclipse. In Eclipse when I can write a Java program and it will compile and run fine. Then I can make a change to the source and when I run it again sometimes the old version of the code without the change in the one that is run. If I hit run a second time the new version is run.
In NetBeans I get a different error the second time I try to run updated code. "Could not find or load main class". This happens sometimes when I make changes to the source. I think this might have a similar cause to what is going on in Eclipse. In both cases the problems are intermittent and difficult to reliably reproduce.
I am using JDK 7 but before I was using JDK 8 and had the same problem.
I don't know about netbeans but in eclipse if you change code and you don't save before launching sometimes it executes the old code. So ctrl+s or hit the button save before launching every time. It seems that the run and save command are not issued by eclipse in the same order so it runs and saves at the same time but runs the old code.
i don't have the rights to comment right now so here it goes, i faced the similar problem when i was using net-beans 8.0. the main reason behind this problem is your classpath.("could not find or load main class").one way to ignore this problem is to set the classpath as the current directory(which can be done by using " set classpath=*;".). kindly revert if this doesn't solve your problem.
p.s: try it to compile with dos.
"C:\Program Files\Java\jdk1.8.0_05\bin" and you are good to compile.
and in eclipse, when the present src code has some errors.. it tend to compile and run the previous code.
I'm writing an Android application and there's some Java code in it that's somewhat sophisticated and therefore hard to verify the correctness of in the Android environment. I would like to run this code in a desktop environment where I have more tools with which to examine the output of this code while still using it in my Android application.
My attempted solution is to have three different projects in Eclipse. My Android project and two plain (non-Android) Java projects. One Java project has the sophisticated code that I want to use in Android and the other is a test program that verifies the correctness of the former project. The latter project has already been useful in debugging the former.
However, so far, my attempts to use the Java project in my Android project appears to work in the IDE but when I actually run the Android application, the NoClassDefFoundError exception is thrown whenever I try to access any of the classes. Obviously, that code is not being recompiled into the .dex file but why not?
I could go into detail about what I've done so far but I can't help but think that what I'm doing is a pretty standard and simple thing and there's a plain way of doing it, even though I can't find anyone doing quite what I'm trying. Can someone describe to me how this is done?
Luckily, I found the answer to my own question and I thought I'd share it here to help others in the same situation. It turned out to be very simple...
What I was already doing would have normally worked, which should have been a big clue to me since I have actually done this before, successfully. All you have to do is, under your Android project's Properties > Java Build Path > Projects, add the plain Java project to your "Required projects on the build path" and then under Properties > Java Build Path > Order and Export, check the checkbox of that same project in the "Build class path order and exported entries" list and everything should just work.
From within Eclipse, there's nothing else you need to do to get this setup to work. It's only when you're compiling from the command line that you need to build Java Jars and import them as libraries but I'm not doing that (yet).
Finally, this wasn't working for me because I just happened to be compiling my plain Java project under JDK 1.7 compliance, while my Android project was compiled under JDK 1.6. This is verified by the output on the Console pane, reporting "Dx bad class file magic (cafebabe) or version." This error message goes away when both projects are compiled under the same compliance level and, not coincidentally, the Android program runs properly.
Thank you to everyone who tried to help and I hope this answer is helpful to someone out there!
Would it not work if you made your other plain java project into an Android project and use it to monitor the output on the device?
I have an urgent and puzzling problem with Eclipse. My system crashed on itself this morning, and after I rebooted, I can run a program perfectly within Eclipse, by right-click on the Java file and choose 'Run as Java Application'. However, after I make the project into a .jar file, and execute that, the behavior of the program simply does not reflect what the code does.
I have checked that I am compiling the right project, and running the same code from the same project within Eclipse does not cause any problem. And btw, I am using a plug-in called fat jar to compile the .jar file, if that makes any difference. I have used the same plug-in numerous times before to compile the very same project, and never had any problem.
Does anyone know what might be causing this weird/inconsistent behavior of Eclipse? Do I need to re-install Eclipse and fat jar to fix this? Thanks.
My usual procedure for strange things like this is,
A) Clean and build again i.e. Project -> Clean
B) (not so eclipse related) Since I am usually using a build tool, do the same thing from the tool to ensure its eclipse.
C) If it gets really bad, I'll start a new eclipse workspace and try from there.
D) Iff I had just installed a new plugin before things went strange I'd think about reinstalling
It sounds extremely strange :)
But Eclipse can, and has, acted strange before. I have had problems in both Java, C++ and PHP development during the years that could only be fixed with a resinstall of Eclipse. You could probably fix it by digging around, but the time it takes to find and fix these types of strange problems in Eclipse is simply not worth it.
Good luck!
Please try to Reset Perspective first (Before reinstall eclipse)
Window->Reset Perspective.