Required imports to execute qrcode? - java

am trying to encode the values given in an Text View into an QR code at the click of a button.
i downloaded zing 1.6.zip and don't know which one to import among all the folders for my process
i try with this website http://www.onbarcode.com/products/android_barcode/barcodes/qrcode.html
but nothing went good with it, what class files i need to import in order to execute the above code

Add the OnBarcode.AndroidBarcode.jar file to the libs directory of your android project.
Then make sure you add it to your classpath. If you're in eclipse, you can paste the file in the libs directory. Then right click it -> Build Path -> Add to Build Path.
At that point you can start using it:
QRCode barcode = new QRCode();
And again, in eclipse, as long as you have the jar file on your build path, can do a ctrl+shift+O to fix imports and pull in the correct class imports.

Related

How to import source files in Java to use in another project

I have been writing a project in Java that I've called NHL2 and at this point in the development I've decided to try to incorporate wheels which can be found here. I've downloaded and unzipped the folder, and tried to import the files in several different ways. In Eclipse I've tried right-clicking the NHL2 project and importing it. The files get inserted into certain places in the project but when I type import wheels.etc.* for instance, it gives me an error and says it cannot resolve the import. So I tried deleting the imported files, right-clicking the package containing my files, which is also NHL2, and running the import command through there. Again, same basic problem.
I've also tried just creating a whole separate project titled wheels and importing there. This seems to be fine and the wheels project itself has no errors, but still I cannot import those files in my NHL2 project. I've tried looking up YouTube videos and other stackoverflow questions because this seems like it's just so basic that it should have been answered by now, but I can't find it.
Create a new Folder in your Project, e.g. called "lib"
Copy the wheels.zip into that Folder
Open the properties of your Project (Alt-Enter on the Project)
Select "Java Build Path"
Select the Register Card "Libraries"
Click "Add JARs"
Select "Yourproject/lib/wheels.zip"
Click "OK" then again "OK"
Though it is no jar file (but a zip) it works. I tested it.
This is because the zip contains the class files and the source files as well.

How can I avoid this Ant Build error?

What is this ant build error in eclipse?
When I click the Ant Build I have the error message shown below.
Build failed
Reason: Unable to find an Ant file to run.
Could you please help me solve it?
Quoting from here
Create a new project in Eclipse
After the project is created, look in the package explorer window pane on the left and right click on the src folder.
There are two methods for the next step, you could either add a New > Class, and then copy and paste everything from your old java file to the new class (make sure the class name is the same), or the better route would be to Import.
After clicking Import, select File System under the general folder. Click Next.
Browse for the java folder where your source files are located. Once you click ok, it will add all of the source files to the right pane.
Select which files you want to add and click Finish.
Now if you look at your Package Explorer window you should see the source files. Now just compile them, and the error shouldn't appear and you can run them just like before.

How to import an api library to eclipse? JAVA

first of all, thanks for all the times this comunity helped me, and sorry for my english.
The problem: I want to use a public library for the RIOT games api, this library:
https://github.com/aaryn101/lol4j
When i tried to add the library eclipse don't recognize the classes!
I dont't know how to add it!, i searched, really, but i can't find it, thanks!
pd: I'm using Eclipse!
Here is an example from the library:
Lol4JClient client = new Lol4JClientImpl("apiKey");
ChampionListDto championList = client.getAllChampions(Region.NA, true);
RecentGamesDto recentGames = client.getRecentGames(Region.NA, 19163557);
Map<String, LeagueDto> leaguesData = client.getLeaguesData(Region.NA, 19163557);
PlayerStatsSummaryListDto playerStatsSummaries = client.getPlayerStatsSummaries(Region.NA, 19163557, Season.SEASON_3);
RankedStatsDto rankedStats = client.getRankedStats(Region.NA, 19163557, Season.SEASON_3);
MasteryPagesDto masteryPages = client.getMasteryPages(Region.NA, 19163557);
The library hosted on github contains a gradle build script that you can use to build a jar file. If you don't already have gradle download it from http://www.gradle.org/installation and configure it.
Extract the ZIP
Rename junit.properties.sample to junit.properties and enter values for variable defined within the file.
Assuming you have access to a terminal or the command line, run the following command from the lol4j-master folder: gradle jar
You should have something like the image below. Then you can import the jar file the normal way into your project.
PS: This method will save you the headache of downloading the necessary libraries.
Running the command: gradle jar:
tshenolo$ gradle jar
Download http://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.3.0/jackson-databind-2.3.0.pom
Download http://repo1.maven.org/maven2/com/fasterxml/oss-parent/11/oss-parent-11.pom
Download http://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/2.3.0/jackson-core-2.3.0.pom
Download http://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-annotations/2.3.0/jackson-annotations-2.3.0.pom
Download http://repo1.maven.org/maven2/org/glassfish/jersey/core/jersey-client/2.4.1/jersey-client-2.4.1.pom
Download http://repo1.maven.org/maven2/org/glassfish/jersey/project/2.4.1/project-2.4.1.pom
Download http://repo1.maven.org/maven2/net/java/jvnet-parent/4/jvnet-parent-4.pom
Download http://repo1.maven.org/maven2/org/glassfish/hk2/hk2-bom/2.2.0-b21/hk2-bom-2.2.0-b21.pom
Download http://repo1.maven.org/maven2/org/glassfish/jersey/core/jersey-common/2.4.1/jersey-common-2.4.1.pom
Download http://repo1.maven.org/maven2/javax/ws/rs/javax.ws.rs-api/2.0/javax.ws.rs-api-2.0.pom
Download http://repo1.maven.org/maven2/com/google/guava/guava/14.0.1/guava-14.0.1.pom
...
BUILD SUCCESSFUL
When you download a ZIP you are probably downloading the full project sources, project, etc.
You need to either extract that to your hard drive and then load the project in an appropriate IDE and build it or look and see whether the project you are downloading offers a JAR download.
Either way what you need is a .JAR file either downloaded or produced by building the project. That JAR file can then be imported as a library.
In Github, you can download the master copy (Download Zip).
Steps to add to eclipse:
This will include the classes in your project
extract it
copy the folder "lol4j" under lol4j-master/src/main/java to your project folder's src/
refresh the project
In the same project, in your classes, you can already use the api provided.
import the necessary classes when you see error (by Ctrl+Shift+O or right click the red cross)
some dependency jars are needed:
e.g. com.fasterxml.jackson.*
you may need to import those dependency jars (by download from google) to the project as well by right click the project ->
edit Java build path -> Libraries -> Add External JARs -> browse and add
P.S. I have tried myself in Eclipse, and it works

Android Using Jar Files

So I'm trying to use the jReddit wrapper class because I am developing a reddit app on the android. Here is what I did:
I first went to jreddit and downloaded as a zip
Then I went to eclipse, made a project and copied the files from the extracted folder into the new project. Here's a picture of what it looks like:
Then I used the build.xml from here and "Ran as Ant" to create a jar file in the dist folder as you can see above
I made my android project and copied the jar file into the lib folder and built the path. The project looks like this:
Finally, here is my MainActivity.java. Sorry, I couldn't format the code properly on here
There are no errors, so I can run it on the android. However, when I click the login button to activate the function call onClickBtn, before it can even get into the function it throws an error saying: Could not find class 'im.goel.jreddit.user.User', referenced from method com.example.reddit.MainActivity.onClickBtn
Did I not import this jar in correctly or am i just not using it properly? Why is it compiling fine like it can see the user class but when run on the android it doesn't know what it is?
Extract the contents to the same folder as your other classes. Usually src.
Or
Go to project properties (Alt + Enter) and select Java Build Path (Left panel). Then select Libraries (Top middle). Click the Add External JARs button and select your jar.

How to take package .java files into a Eclipse Project

I've got a copy of a java package, with example implementation. The package is in a structure called com.java.project (folders, containing myriads of .java files) and there's also a few example files (example1.java, example2.java)
The example files have 'import com.java.project' calls in them, that's all well and good. However, I can't seem to work out how to get Eclipse finding the package contents (currently returns "Type not found" for any calls to the project objects.
I've tried placing the com structure in the same level as my example1.java, but that doesn't work. I have read that I need to compile the package into a .jar to get it to work w/Eclipse, but that doesn't seem to want to behave, none of the files compile.
In Eclipse you can right click on the Project Explorer and select "New -> Java Project"
Then you can import your java files by right clicking your project, selecting import from file system. If the class file shows an error, open the class file, the class name should have red curly braces, click on the error tick mark and Eclipse will give you an option to move the file to the correct package which in turn creates the folder structure for you.
1.Can you do a check on the build path of your Java project? (Right-click the project -> Properties -> Java Build Path -> Source tab), and see if the root folder contains the code is properly specified here.
2.Maybe a Project->Clean will help as well.
Hii,
Just Create a new project with File -> New menu
you need to open Java Perspective and there you will find a package named "src" you need to copy your "com" directory and paste it at the src folder.
I hope this will work for you.

Categories