Making library in leJOS

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

User avatar
ProHacker
New User
Posts: 24
Joined: Mon Dec 25, 2017 8:50 am
Location: Russia

Making library in leJOS

Postby ProHacker » Tue Jan 02, 2018 1:31 pm

Hello, programmers!
Please, help me with creating a library in leJOS! What I need to do?
Thanks for fast answers!
LeJOS rules! :D

User avatar
gloomyandy
leJOS Team Member
Posts: 6047
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Making library in leJOS

Postby gloomyandy » Tue Jan 02, 2018 1:39 pm

You need to actually do some work for yourself (or ask your teachers for help if you are still at school/collage). leJOS is just a way to use Java on the EV3. Spend some time looking for Java tutorials (and actually following them) there are many of them out there.
leJOS news https://lejosnews.wordpress.com/

User avatar
ProHacker
New User
Posts: 24
Joined: Mon Dec 25, 2017 8:50 am
Location: Russia

Re: Making library in leJOS

Postby ProHacker » Tue Jan 02, 2018 1:57 pm

Andy, see my profile, and u'll understand that I'm not studying in college, also my teachers haven't work with leJOS yet. I knew about it surfing the internet.
LeJOS rules! :D

User avatar
gloomyandy
leJOS Team Member
Posts: 6047
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Making library in leJOS

Postby gloomyandy » Tue Jan 02, 2018 3:52 pm

The advice I've given you still stands, if your teachers know anything about programming they can help. If you want to learn more then forget about leJOS and spend your time studying how to use languages like Java and general programming principles. There are lots of resources out there to help you.
leJOS news https://lejosnews.wordpress.com/

User avatar
ProHacker
New User
Posts: 24
Joined: Mon Dec 25, 2017 8:50 am
Location: Russia

Re: Making library in leJOS

Postby ProHacker » Tue Jan 02, 2018 4:00 pm

Andy, I've viewed leJOS system files and saw that library is only a .java file.
LeJOS rules! :D

User avatar
linuxtardis
New User
Posts: 18
Joined: Mon Oct 27, 2014 5:21 am
Location: Czech Republic
Contact:

Re: Making library in leJOS

Postby linuxtardis » Wed Jan 03, 2018 8:51 pm

Hi ProHacker,
I've been through this learning phrase as well. Here is what worked for me:
  • Start with something small, like with LibreOffice Basic. Displaying messageboxes, playing with numbers, conditionals, loops etc. It should be quite easy.
  • Read a tutorial-book for some language. For me, it was an intro into C# WinForms. Java-book would be even better, but from the language standpoint, these languages are quite similar.
  • During the reading (and even after, of course), do experiments and let your fantasy work. Experimenting and practising are the best ways to learn.
My tip is that you are here:
  • Learn how to search on Google (or on Yandex, it doesn't make a big difference). No, seriously. This is a really important skill you're going to need and that you can apply almost everywhere. Whenever you need to fix something or need to know something, try that. On the other hand, don't go into crazy copying of random fragments of code from StackOverflow. Try to understand the issue.
  • (probably optional) Install some Linux distro. The beginnings are going to be hard, but as the time goes, you'll get used to it. It is entirely possible to happily develop on Windows, but I've come to like the *nix way of thinking.
Well, and to answer your question:
Yes, you are right. In fact, everything in Java can be regarded as a library (don't know about JDK9, it introduces some new format). You write your program into a .java file in the source form. This is then compiled into so called bytecode, which is stored in .class files. Each of these files stores one class. The files are stored in folders matching the corresponding Java packages, where the classes reside. A library, .jar file, is just a bunch of .class files stored in a zip-like format.
The classes are "wired" together at the time the program is run. The JRE searches for the needed .class files in folders and .jars configured in so called classpath.
What are the executables then? Well, they're just a special case of a Java library, which includes a special file called MANIFEST.MF. It contains at least the path to the main function. But, you can start even a Java library without a manifest. It just needs to have a suitable main function. You can specify the main function on the java command line.

Practically, you have to create a new library in your IDE, if you use one. I don't know about Eclipse, but in IntelliJ IDEA it's done by creating a new JAR artifact from a separate module.

Best regards,

Jakub Vaněk
#HueHueHue Productions


Return to “EV3 Software”

Who is online

Users browsing this forum: Google [Bot] and 1 guest