How to use eclipse properly with mendix

0
I am trying to convert string to json using json simple, java-eclipse in mendix. I do the following steps   Create requires microflow, java action, input params, output params. Deploy for eclipse. Open project in eclipse. Configure build path → library → classpath → add external jar → json simple Write code, save changes, run application in mendix, it throws compilation errors, as follows. E:\sub1\javasource\dashboard\actions\Trial.java:17: error: package org.json.simple does not exist import org.json.simple.JSONObject;                       ^ E:\sub1\javasource\dashboard\actions\Trial.java:18: error: package org.json.simple.parser does not exist import org.json.simple.parser.JSONParser;                              ^ E:\sub1\javasource\dashboard\actions\Trial.java:19: error: package org.json.simple.parser does not exist import org.json.simple.parser.ParseException; … …   Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: E:\sub1\javasource\administration\proxies\microflows\Microflows.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 8 errors FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':compile'. > Compilation failed; see the compiler error output for details. * Try: > Run with --stacktrace option to get the stack trace. > Run with --debug option to get more log output. > Run with --scan to get full insights. * Get more help at https://help.gradle.org BUILD FAILED in 4s but in eclipse the build works just fine
asked
4 answers
0

Hi,

You can refer to this documentation : https://docs.mendix.com/refguide/using-eclipse/

answered
0

Hey Sahana!

 

I have seen your comment. To see the application on the web you need to access the localhost URL.

 

To know which port is the application using you can check the run configuration on eclipse:

 

In this case for example the app is running on localhost:8083

answered
0

That looks like you are missing the json simple jar file in your userlib.

If you are looking to turn a data into JSON in a Mendix application, you will probably find it easier to use an Export Mapping. You won’t need to worry about maintaining custom Java code using this approach.

https://docs.mendix.com/refguide/export-mapping-action/

Good luck!

answered
0

Hi,

Add the json jar in userlib folder

App->Show app directory in explorer->userlib->{add your jar}

or

Set up an Export Mapping and Message Definition for the entity you want to convert into a JSON String.

Next, create a microflow and add an activity that uses the Export Mapping you created. Pass the object as a parameter to the Export Mapping and set the content type to JSON. Define the Return variable as a String.

 

Export with mapping:

https://docs.mendix.com/refguide/export-mapping-action/

Message Definition:

https://docs.mendix.com/refguide/message-definitions/

answered