Avoiding missing a main class and def class definition using DropBox and Eclipse for Java

I use Eclipse to write Java code and use DropBox to synchronize my code with other users on different computers. In most cases, everything works as expected: if someone makes changes at both ends, the change is saved, and when the other person updates the Eclipse workspace, the changes go through and can be viewed and successfully launched.

Sometimes one of several errors occurs. Sometimes Eclipse says that it cannot find the main class, and sometimes it says that it could not find the class itself. Sometimes it does not report an error, but for some reason does not actually update the .class file and, therefore, launches the old version, even if the compiler displays the new source code and saves it. I noticed that if I manually copy the code to a new .java file elsewhere in the file system and then compile it, it works fine, but for some reason it refuses to regenerate the .class file, and I need to delete it manually and replace it it to the one that is generated in another project - then it works. But to solve other problems, you need to manually copy, delete and re-paste ....

[Actual errors include NoClassDefFoundError, UnsupportedClassVersionError, and some other errors related to the absence of a main class.]

I understand that the description here is somewhat vague, but, unfortunately, I'm not quite sure what is going on. I hope I just missed some basic fact that will help solve all these problems.

Thanks!

+3
source share
5 answers

I am sure that you will see problems with Dropbox for sharing your source.

Eclipse does not know what Dropbox is doing while it is downloading and downloading updates, and their actions will certainly not be synchronized. At arbitrary points in time, when Eclipse is trying to create assemblies, etc., It will detect unexpected activity, possibly even partially downloaded source files, which may explain the specific errors that you see.

You are trying to do something more complex than sharing photos or documents. I would suggest using a version control system like git or subversion for sharing and source control. Then you can use the Eclipse plugins, which are designed to integrate these systems in an easy to use way. There is a learning curve there, but skills will serve you well.

You can use online versions of these solutions, for example github and unfuddle , if you want to use sharing, backup and source control as a service, for example, with Dropbox. They are also free.

+5
source

Subversion , Git, and all version control software solve all these problems for you.

+4
source

Dropbox is not really an adapted system for exchanging codes. What you have to do is configure SVN and commit only the source files. Thus, you will not have such errors.

+3
source

Dropbox has version control (you can restore old versions of a file) and does not seem like a terrible solution to the problem. I keep the Eclipse repository in Dropbox, so it is available on any computer; but since I use it myself, I have not come across your problems.

There is one case where I see how you ran into problems - this is if your class files are also stored in a folder. It just ruins everything. Make sure you specify the location on your local hard drive for all build artifacts (classes, banks, ...) and that the only things in your Dropbox are .java sources.

In fact, I suggest you not save the eclipse project in your Dropbox, just create an eclipse project and point it to java files in your Dropbox.

If this does not work for you, go with what other people have said here and create an SVN repository somewhere, it's easier than you think.

Oh, another possible problem is dates! You may want to make sure that the date in your java files does not skip back and forth (as can happen if one of your developers was in a different time zone). In this case, Eclipse may not recompile your file.

Also, instead of copying / etc, which you are currently using, try to make the project clean.

Response for requesting additional information:

When you start Eclipse, select / create a workspace that is NOT in your Dropbox. The best place is probably outside your home directory. If you have already specified the default workspace, there should be an element of the switch workspace in the file menu.

Create your own project. select "Create a project from an existing source" and specify the source files in your Dropbox. I think you want to “create separate folders for source and class files” to save class files from your Dropbox. If you see something saying “Copy files to workspace, say no.

This should give you an ongoing working draft. I hope you no longer see these problems.

One more thing can help - and it can work on your existing project - without the above procedure ...

When you update your files (f5) to download changes from Dropbox, select the Project / clean menu and select the project. This should remove all class files and rebuild them.

If your class files are shared on Dropbox, this can still have strange consequences for other people with open eclipse, so I really suggest rebuilding the workspace, as I said above.

+2
source

How to avoid the main class

Provide one. This problem has nothing to do with DropBox.

-2
source

Source: https://habr.com/ru/post/1303051/


All Articles