Cannot figure out error importing jme3 in eclipse - java

**UPDATE:
I closed and re-opened eclipse (which I've done before), and was presented with a new "quick fix" solution of moving the library to the module path (which it has been in before), and now I can reference it, but now
import com.jme3.app.SimpleApplication;
says
The package com.jme3.app is accessible from more than one module: jme3.core, jme3.desktop
my module-info now have warnings as well:
module-info.java:
module vast {
requires jme3.core; //Name of automatic module 'jme3.core' is unstable, it is derived from the module's file name.
requires jme3.desktop; //the same(ish)
requires jme3.lwjgl; // and so on
}
I'm going to fiddle around a bit and see what I can figure about those
**
So, I've decided to migrate one of my projects from LWJGL3 to JME3 (using Eclipse). I followed the advice of Setting up JME3 in Eclipse, specifically downloading the library, extracting it to a lib subfolder in my project, I then added the contents of the library to a User-Library (using Add JARs, since they are in my project), and added the library to my classpath. I know eclipse sees the library (code suggestions), but I keep getting access errors.
Setup:
Arch Linux (latest)
Eclipse IDE for Java Developers (2019-12 (4.14.0))
Here's the code (small test class to make sure it runs before I refactor):
Test.java:
package lab.stone.werlious.vast;
import com.jme3.app.SimpleApplication; //the type com.jme3.app.SimpleApplication is not accessible.
public class Test extends SimpleApplication { //SimpleApplication cannot be resolved to a type
}
module-info.java:
module vast {
requires jme3.core; // jme3.core cannot be resolved to a module
}
I've tried many different combinations of adding the library (modulepath, classpath, user library, external JARs, internal lib JARs), and referencing it. I keep getting errors, even though SimpleApplication suggests importing com.jme3.app.SimpleApplication, which suggests adding requires jme3.core to module-info.
I am not using maven or gradle (detest those), and prefer to do things locally. I also prefer eclipse over jme3 sdk. Can someone tell me how to properly import this library (without maven or gradle)? and how to properly import it in my code? I didn't have this issue adding LWJGL3 to eclipse before, and currently jme3 is added the same as lwjgl3 in my source project (jars in lib folder in project, lib folder added as user library, user library added to classpath).
Thank you all for your help
As a side note, because I'm sure someone will mention it, I've been on various forums for about 2 hours trying to figure this out, including stackexchange. I can't find a similar issue with a solution that works for me.

Related

Weird Behavior when running Java app

The issue:
When Running the Main class the program terminates without doing anything. This only happens when i import libraries to the project, specifically when i import more then 8 libraries. if i remove them from the build path the program loads just fine.
I have tried almost all the combinations to check if it was a specific library, however i found out that it's only the number of libraries that matter.
There are do any errors on the problems tab nor exceptions when running the app. It just terminates.
This are the libraries i'm importing:
commons-codec-1.10
commons-io-2.4
commons-logging-1.1.3
commons-math3-3.6
junit-4.12
log4j-1.2.17
poi-3.13-beta1-20150723
poi-excelant-3.13-beta1-20150723
poi-ooxml-3.13-beta1-20150723
poi-ooxml-schemas-3.13-beta1-20150723
poi-scratchpad-3.13-beta1-20150723
sqljdbc4
xmlbeans-2.6.0
I have the libraries inside the project, in a folder named lib, and i have already tried to import the libraries by using right click>build path>add to build path, and also buy going to project>right click> build path> configure build path and add the libraries there.
Also i'm using a javafx project and java8.

Eclipse editor/build losing access to imported javax classes

I fixed my problem but I don't know how/why this fixed it so I am looking for an explanation.
I opened my project yesterday and I could no longer build due to the fact that the java and jsp imports could no longer see javax.* classes. I had another project that worked fine but could find no differences in their build paths.
After reading several threads on build path, etc. and not finding any problems in the configuration file I simply retyped the import in one of the source files, eclipse was able to lookup class tree as I typed in the editor, and once one of the imports was retyped the project would now build.
I would like to understand what in the Eclipse project configuration was hit and why this happened and how this method I used actually resolved the problem.

IntelliJ multiple Modules which lie in the same package-namespace?

I try to migrate from eclipse to IntelliJ IDEA 13.
Up until now I had multiple eclipse projects which are all in the namespace xxx.yyy.zzz.
(Kind of a plugin infrastructure with one main app and plugins using the same namespace...).
After migrating the eclipse projects to IntelliJ modules everything builds fine, until I open a File of the main app. IntelliJ then complains: "Package name "xxx.yyy.zzz.Foo" does not correspond to the file path "src.xxx.yyy.zzz.Foo", and therefor also fails to find the imports depending on this package.
This happens even though I set the source-folder to src. The weird thing is: This only happens to some of the imported modules, others (in the same namespace) are fine.
And also the modules which show this behavior start behaving like this only after I import other modules (so I guess there is some problem with conflicting package-namespaces in modules?)
Any input would be highly appreciated, since I can't find a solution to this.
Thanks!

Android gradle import lots of errors and trouble

Im trying to get used to this new gradle system built into the new Android studio.
I've tried a really basic task, to import the websockets library into my project. So I imported the module via the normal route (File->Project Structure), I imported the java-websockets module in and added it as a dependency too. Finally I import the org.java_websockets class into my project.
My project ended up looking like this:
So this is where my problem starts, I give it a shot and try to build it and run into the usual gradle errors. So I added an 'include' line to my settings.gradle
include ':java-ws-client'
and another one into my build.gradle
compile project(':java-ws-client')
So now I find myself stuck with two problems:
One fairly undescriptive one:
and another:
I've tried updating my android studio to the latest one, and the project above is a fresh one.
How can I avoid pulling my hair out?
From your screenshot, settings.gradle is inside TestProjectProject, which makes TestProjectProject a root project. However, java-ws-client is parallel TestProjectProject, which is outside of TestProjectProject's scope. You cannot reference any project outside its scope using ":foobar" notation.
To fix the second problem, you should either move java-ws-client into TestProjectProject, or declare java-ws-client as an external dependency, and add proper repository resolver to find it.
To fix the first problem, make sure in TestProjectProject/build.gradle you have applied the Java plugin. The Java plugin creates the "default" configuration.

referencing (pure java) project in Android project (Could not find class)

I am trying to reference a pure java-Project in my Android-Project -> The Java-Project has a whole bunch of classes I need to use. Oh, and as the first response pointed out: I am using eclipse, yes :)
Only Problem is: I Always get Could not find class 'XXX', referenced from method com.example.helloworld.MainActivity.onCreate. I seem to have missed SOME step or error...?
What I already did:
The Project is added as Project into the Java Build Path (logically nessecary)
It is marked in "Order and Export" in the Java Build Path and pushed to the top (this solved the problem for someone else here when dealing with Jar-files)
Ir is marked in "Project References" on Project settings.
I added the folder where the relevant class is under "Libraries" in build Path... I am not sure if that should be nessecary.
The Java-Project I reference has a whole load of Jars, but if that is the reason, should I not get a different errormessage?
I had the same issue and after some hours of frustration and search I have finally found the answer here:
Android, class not found from imported jar file
Basically, the issue was that the referenced pure-java project or the generated jar was built with Java 1.7, and Android projects are set to use 1.6.
Two ways to do this.
Jar that java project and copy the jar to the libs folder of your Android project.
Add the project as a dependent project to your Android project
Both work wonderfully.
But mind you, this pure-java project must add android.jar and not things like rt.jar :). Else you will get Dalvik exceptions.
Edit :
Dont forget to refresh and Project - Clean your android project.
Two things to check (you mentioned you are using Eclipse):
If your android project needs to use the pure-java project's JARs, check that those JARs are being exported in the build path options of the pure-java project. This is in the build path of the pure-java project you are trying to include, not the build path of the android project that is trying to include it. Under "Order and Export" tab for the pure-java project, note the comment "Exported entries are contributed to dependent projects". In this case, your android project is the dependent project and your pure-java project needs to do the contributing.
Make sure the pure-java project is actually opened in the IDE in addition to your android project. Probably trivial but sometimes overlooked.
If answer does not suffice, you may wish to mention if the missing classes are in .java source files, or if they are only found in JARs in the build path of the pure-java project
Edit: To further track down the issue, please confirm the following to make sure I understood your question:
The pure-java project does successfully build in the IDE
The 'class not found' error is one you are getting when you try and -build- your android project and not when you try and -run- it.
CLASSPATH (aka build path) can be nasty to untangle. If including the project is not working (assuming it does build), you could try building a JAR of your pure-java project and copying (and including) that and all the other JARs into your android project.
The android SDK does certainly complicate the build environment. One way to find out whether the problem is (A) your android project setup) OR (B) the way the pure-java project is packaged) is to create a different pure java project and try including the first one, preferably using the -exact- same line of code that gives you the build error in the android project, if possible.

Categories

Resources