Java as backend? Need Explanation


#1

Hi guys,
first of all: i am completey new to ionic!
I have experience in Java programing. And i have to program a application for my studies.
I’d like to do this in java. A hybrid webapplication using a database.

How do i connect ionic with java ?
Can i use ionic as a UI framwork for java ?

I found many examples and i specially likes the whole UI design and possibilities!
In all examples everybody used JavaScript. And i am a total noob to JavaScript so i wondered,
if you can write a whole application with javaScript.
I know that sounds like i am a total noob to all programming things but actually i’m studying
computer science and i really want to develop a good working and save application.
I hope that i found the right forum, and sorry if this topic is wrong here.

Thanks in advance
Alex :smile:

[also sorry for my bad english, i am not a native speaker … ]


How to establish connection from ionic to spring controller
#2

First you can’t use Ionic as a UI framework for Java, it’s strictly a client-side framework.

You will need to have a separate client and server side code. Client side code needs to be written in JavaScript, technically in a combination of vanilla JavaScript and AngularJS.

Server side code, in your case, it will be Java.

You will need some Java framework. My advice you should use Play Framework or Jersey, find more about them plus some other frameworks here: http://www.gajotres.net/best-available-java-restful-micro-frameworks/

Here’s a tutorial series on Ionic: http://www.gajotres.net/ionic-framework-tutorial-1-installation/ . Rest of them can be found in Table of Content section.

P.S. Your English is more than adequate :smile: feel free to ask more questions any time you want


#3

Thanks for your answer…
Just for my understanding :
it is normal to write the client code in javaScript :o ?
respectively do i really use single JavaScript for modern Apps using ionic ?

As i understand you, i can still use the sooooo nice UI of ionic ?
So ionic is more a all-in-one framework ?

So the JavaScript hands over the data to the Java Code on the server?
Well, seems like i need some more background info on webapplication :frowning:

:grin: guess that are enough questions :smiley:


#4
  • Ionic is an application framework for hybrid mobile apps. Which means apps built with JavaScript and wrapped with Cordova or PhoneGap into a native package (Android/iOS you name it).

  • The Ionic is all about vanilla JavaScript and AngularJS.

  • Ionic UI can not be used outside the main framework, there’s no point, it’s too tightly connected with underlying AngularJS.

  • It depends on what you mean by all-in-one framework?

  • Client side application will communicate with server-side through REST calls.


#5

Okay i think java-servers are for the most purposes overdone in the web like simple APIs (where you need no hard background processing like video converting and so on).
But like Gajotres explains you need to write serverside code (the api) and clientside code with Ionic.

Keep in mind ionic is for mobile apps!

if you need only a webapp you can easily use Java Servlets or JSPs… no need to use two technologies.


#6

i think i need something of everything :smiley: :

  • The application should be a mobile application for tablets.
  • The user can model data
    [I don’t know how much i can talk about the concrete content of the app because it’s my bachelor thesis …]
  • the modeled data has to be stored in a database
  • so the data can be edited and used by many users

So actually i think a server for central databse is necessary, isn’t it ?
Actually i still search for a appropriate solution…


#7

okay then ionic is the right choice… even for a “small” bachelor thesis you should not take toooooo much time to learn new frameworks so html5 and javascript should be fine… i do not know if java is that relevant… but it is your choice.

i would prefer node (it is also javascript and you can build up with the expressjs a API very fast … i think in some minutes and it is very new and innovative) or some easy going old php/perl/python scripts.

But with every backend technology you need the database and API - endpoints the client can send request to and logic to read and write data to the database.


#8

For java backend server, you could have a look at JHipster.


#9

Hi,

I am using java based backend for my ionic app.

I have written a java based rest service using spring framework. Since RESTworks over http, I use “$http” in angular to communicate with my backend and it works like a charm.

Hope this helps.


#10

thanks for the replies!

@bengtler
actually i don’t know any way else for the backend. I mean java is the (only) programming language i have experiences with, so it seems like a good way.
sorry, but i do not understand your last answer completly…
//as i understand i should use ionic on the client side ?//
ok i googled a lot and found out that JNode is for the server side…
and it seems to me that there is a huuuuuuge discussion going on wether java or JS is “better” or at least where
the advantages are on both sides. here everybody discusses alot in the comments…crazy.

one important point is that i have to start the whole development process and that the applications will be increased in
features and the whole scale. So any used technology should be able to be scaled…
I am a typicall student learning the theoretical side of programming and software engineering java looks better from my point of view. But, as you may noticed, my view is sooooo small, so i’m thankful for your tips and advices :slight_smile:

And you would prefer jNodes on the server side instead of java?

So my logic would be written in JavaScript
[oh man i think i’m really not up-to-date :smiley: Never expected that JavaScript can be used for a real logic.
I only knew JS for creating dynamic content on websites… ]

anyway a question about the connection:
do i need to develope an own protocol ?

@gmarziou and @vinihi83:
i will have a look at JHipster and Java Spring for the server backend!

I am so overhelmed with all the frameworks and possibilities, sry if it seems so noob-like…


#11

I dont want to pollute ionic forum with java pointers. Check your inbox. :smile:


#12

@vinihi83 hehe :smile:
@TAlexT
i do not mean jNode only NodeJS or Node it is a server side programming framework based on javascript and google chromes v8 engine.

But i understand you. In most computer science studies you only learn a little bit Java. I was lucky to have a little bit c-basics as well.

If you only know Java use Java but you have to keep in mind maybe for the future:
If you need an api that only stores data in a database and read data from that database a java-Server with java backend is very complex.

You should choose a technology that fits your needs best.


#13

oh man i am confused.
I think i meant NodeJS (wrote about the google chrome backgound)…

Right, keep the future in mind.
I thought java would fit better for a “bigger” application, does it ?
in the current situation java might be like “using a sledge-hammer to crack a nut”…

Actually i need to know what my needs are xD
I have an appointment with my professor on monday…will check there my needs.

Maybe i am a little bit afraid of using JavaScript, when i’ve never done it before.
Is it an easy change from Java to JS ?

thanks vinihi :slight_smile:


#14

Several questions you should ask yourself before choosing a technology:

  • how much time do you have to do this. Don’t underestimate learning rampup.
  • what is the platform for your server? Windows, Linux, OSX ? For
    instance Windows is not the best choice for developing in NodeJS.
  • which database?
  • Is using a backend service in the cloud an option? If you have only few weeks, consider it.
  • Will you be able to get local support for chosen technology from your teacher or other students?

You will have to learn it anyway if you write an Ionic app.
The question is not only to learn a language, it’s to learn a framework and related tooling.


#15

thanks @gmarziou!

i’ll think about the points and i hope i get some more answers on monday.

  • time : is from now to december/january. But i still have regular lectures and i have to write a paper in which i present the software and how i worked etc…
  • i think I can choose between linux and Windows for the server, and i know that existing projects are running on cloud servers. I’m working with ubuntu at home.
  • database i might get some advices. I’m doing my Bachelor thesis at the institute of databases and information systems at my university.
  • i think there won’t be much support…

You’re right, i have to learn it anyway…


#16

Another advice:

how deep are your java skills. if you only did the university stuff … programming little object orientated program with a simple gui and so on or do you just have the knowledge to write server and api code.

In my opinion you are faster to read about nodejs + expressjs as api-framework and something like a documentbased databasesystem like mongodb instead of learning java-serverside code.


#17

ok, i had my conversation with my professor and a research assistant.
The assistant guy said that ionic is just for “transforming” html+JS+CSS aplication into a native iOS or Apps.
I didn’t want to disagree … but i thought i can write my application “in ionic” (using HTML+JS) for web, iOS and Android-platform. It’s disappointing for me that the assist precluded ionic as my framework :frowning:
He suggested just using JavaScript+HTML.
Now i’m kind of very confused why it’s not possible to use ionic? Is he right or
Now another assistant (who knows more about technical client-side frameworks) is searching a suitable framework, especially for drag and drop (the main ‘action’ on the GUI)…

Acutally i would like to know if i can write my application “in/with ionic” and where the different is to “using HTML+CSS”… so confused :confused:
i do not want to disagree with the assistant because i think i know less about alle the framework and technologies i may use.


#18

I don’t understand: you are doing your bachelor degree thesis with Ionic (HTML + CSS + JavaScript + AngularJS + Cordova) and Java but you don’t understand the actual architecture? This is quite scaring…

Nonetheless, Ionic, without considering the tools, documentation, support and community, IS JavaScript + HTML + a little bit of native language (Objective C on iOS, Java on Android). This additional bit of native code do actually wrap the HTML5 application to look like a native one, but it will still be JS + CSS + HTML (can we say just HTML5 from now on?).

There is no transformation as you named it, there is a wrapping though. This wrapping is performed by a tool called Apache Cordova, formerly known as PhoneGap.

Other similar instruments exist, I refer to Ionic as the one using AngularJS, which happens to match with my preference among the many available JS frameworks out there.

By just using HTML5, as your research assistant suggests, you will not build an hybrid application, but a web application: the assistant is trying to remove a layer from the technology stack you picked, in my humble opinion as a consequence of your lack of understanding, in order to make your life easier.

If I were you I would listen to the guy, but keeping an eye to Ionic, getting back as soon as you will have finished your thesis: ionic is great!

If you want to be smart and show the guy you are better than he thinks, you can build both solutions with limited effort, but first focus on the one he is pointing you toward: he is on the handle side of the sword!

To build both solutions what you will have to do is ensure to build your web app (HTML5) so that all interactions with the database occur through RESTful services.
Building the plain HTML5 application you can still use the Ionic CSS and JS models to create the web application UI, but you will not be able to use any of the Apache Cordova plugins and your usage of the Ionic CLI tool must be wise.
If you do so, converting the plain web app into an hybrid app will be a matter of running a couple of Ionic CLI commands.


#19

thanks for you response!

yeah. i find this scary, too. Anyway the topic of the thesis is interesting but my assignment is the implementation. So i did not know what the technologies would be. And i am just so much confused with the stack of frameworks (which uses which “under-framework”…). I’ve never learned anything about JS in any lectures, so yes: it’s scary but that why i want to learn it now and that’s why i am so thankful for answers like yours!

Yeah, you’re right. Fewer Layer might be better for me…
Also (as i understand it now) other JS-Framework than AngularJS might be easier to learn and enable a more direct way. The other assistant suggested JointJS because it’s a direct way for a graphic editor (which is more or less what i want to have in the end).

that’s exactly what i think. i do not really have the knowledge and am in a “weaker position”.

The current state is that i will work through JointJS. Looks quite good for graphs and connected rectangles etc.

Through i will have ionic back in my mind.
So maybe it can be used also via ionic… i’ll see.


#20

Well, I never used JointJS, but to me it looks it has nothing to do with what Ionic does :smiley:, so rather than considering it as a replacement you should considering it as another tool, something sitting on the side.

If you were looking at Ionic you intended to create something working on mobile devices and your direction is to work on the web, so what you need is something to help you in building the UI fundamentals (navigation, buttons, input fields, etc…) and the navigation (“when this button is clicked go to that screen and load new data” stuff).
The data storage and retrieval will be done in Java, so you need a way to communicate the data residing on the server to the application residing on the client (the latter is not mandatory, meaning you can build the HTML UI on the server and just send it to the client, but that’s not what I would do).

You can build every button and style them on your own, or use Ionic and AngularJS: it’s your choice :wink: