Reading from USB port [duplicate] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I'm trying to write a java application that accesses the usb ports to read from and write to a device connected through usb. The problem I face is that I don't know what exactly to use in java to do such a thing. I searched online and found something called JUSB but all the posts seem fairly old.
Currently I'm using the RXTX libraries but I sometimes run into some sync error. When I use C# to do the equivalent it requires far less code and I don't face any of the same sync error.
My question is, is there anything built into the latest version of the JRE I can use to access the usb ports (that is just as easy as the equivalent C# code)?

Been using usb4java for a year on cross platfom (Linux and Windows) and it works great.
See:
http://usb4java.org/
They are very active and have a very good javax USB front.

There is nothing equivalent to C#'s USB support in Java. Both jUSB and Java-USB are severely out-of-date and likely unusable for any serious application development.
If you want to implement a cross-platform USB application, really your best bet is to write an abstract JNI interface that talks to Linux, Mac and Windows native libraries that you'll have to write yourself. I'd look at LibUSB to handle Mac and Linux. Windows, as you've seen, is pretty straightforward. I just came off a year-long project that did just this, and unfortunately this is the only serious cross-platform solution. If you don't have to implement on Windows and your needs are limited, you may get by with one of the older Java libs (jUSB or Java-USB). Anything that needs to deploy on Win32/Win64 will need a native component.

You might want to have a look at usb4java - http://usb4java.org/index.html it appears to support Windows, Linux and Mac OS's and appears to be reasonably current at the time of posting. Is unfortunately under the LGPL so may not be suitable for commercial development.

See the jUSB or usb4java libraries.

The Java Communications API. This should provide similar functionality to the C# System.IO.Ports namespace.

If you're on a mac, USB's can be accessed with the /Volumes/ directory.
Example:
You want to write to a file in "Drive", so the filepath would be:
/Volumes/Drive/file.whatever
Not sure how it's accomplished on other platforms, but this is the simplest way I've found on a mac

Related

What is the best way to test C++ android apps written using visual studio. Without upgrading to windows pro [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
This is the scenario, I am writing C++ applications, and would like them to be multi platform; therefore, I am using visual studio (2017 RC). Due to the fact I don't want to upgrade my PC to windows 10 pro I can't use the emulator that Microsoft provides, so I need to come up with a solution, which is:
1) write the c++ application using visual studio
2) copy that code into android studio then compile and run to test the code
This method works because once the code is in Android studio it is easy to compile and run on the android emulator; unfortunately, it is a tedious process. What I would like to know is would it be best to write a shell script, java program, C++ program, or other program to automate this process. If you think a shell script would be best please provide an example, because I suck at using shells (Note the platform is windows). Please describe why your method is best, and I'll mark correct the answer that appears to be the best solution. Lastly you should know the process will be done many times (every time I make a change to the code worthy of testing).
If you need more information ask in the comments and I will provide it if I can. Also note if you have a better solution than copying the code into Android studio those answers will be acceptable to.
You can try using Nvidia Nsight Tegra, as long as you are willing to test on actual hardware, and not an emulator.
Develop, build, debug and deploy native applications for Android, the world's most popular operating system, using Microsoft Visual Studio, the world’s most popular integrated development environment.
The workflow is quite similar in Nvidia Nsight Tegra as it is for native Windows development, except for the extra toolbar to determine the target hardware.

Why Android support java but not other languages? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
I see the statement below on Google in one form or another
Most of the Android development is Java based because Android supports
a large number of Java libraries
I am coming from Java based web application background. I have never heard the statement "Windows supports one specific language but Linux does not". Then why in context of mobile OS we say android supports Java. The role of any OS is to execute the commands and not to support the specific language, right?
I know I am missing something basic here, but what's that?
Then why in context of mobile OS we say android support java.
I do not know who "we" is. Experienced computer programmers would not say that, and even your made-up quote does not say that.
Role of any OS is to execute the commands not to support the specific language right ?
Correct. And, given a rooted Android device, you are welcome to try porting any language you like to Android, and in a custom ROM mod, you are welcome to arrange to allow the user to run any program they want in any of those supported languages.
However, most people do not have rooted Android devices.
On a normal Android device, the Android frameworks put some limitations on what you easily can use for programming.
For example, you can divide the world of Java-capable servers into two main categories:
Those where you have complete control over the server, which is roughly equivalent to running a rooted Android device
Those where all you can do is upload a WAR and related files (e.g., static assets), which are run on a Java-powered server managed by somebody else
In that latter scenario, you are not going to have complete flexibility in programming. Presumably, you could integrate JVM-based scripting languages, but you may have difficulty in using C++. That is not an issue with the OS — the server itself is probably perfectly capable of running a C++ program. It is an issue of the framework in which your code is running (whatever people use for WARs nowadays, as it has been a long time since I worked in server-side Java development).
The primary framework for Android development is based on Java. Courtesy of WebView, this also opens up hooks for hybrid development (HTML/CSS/JS). NativeActivity makes it possible to write full Android apps in C/C++. Various toolchains allow you to write in other languages (e.g., Kotlin) that compile into something that works with Android's frameworks, and you can embed scripting languages. But you still need to stick to the frameworks, which puts some limits on what you can do and how you can do it. This is not the fault of the Android OS, but rather the frameworks.
Yes, Android is based on Java. But recently the grandpa Delphi acquired fire monkey, which is supposed to transform Delphi code in to native Android code. That way it supposedly run just like a native application.

Code sharing on IOS and Android mobile apps using C++ or Java [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
Are there any libraries or methods that would make sharing code between C++/Java and IOS/Android easier? I realize we have JNI and IOS can use C++ pretty much directly, but it seems like it could be easier.
Microsoft Universal Windows Apps and Chrome Apps are (sort of) doing this.
Open Source is preferable.
I'm using Qt Creator a lot. With the latest versions, you write your whole application in C++, using Qt toolkit, and you can compile it targetting PC, Android and iOS (never tested this last one). If you need to call some SDK functions not available in Qt API, they provide wrapper objects to create and manipulate Jni objects, and you can also execute pure Jni code (loading a java file) if you want to.
If you are looking to share Java, you could try to use this: https://github.com/google/j2objc. I am not certain I'd say that it is easier than using C++. Each option will have some challenges. The downside to j2objc is that it is a translation of Java to Obj-C. So if there is a bug in it (note the comment in the desc which indicates it is between alpha and beta quality), you will need to figure out how you deal with it.
Admittedly, I have only done limited Android dev, and for that, it used the NDK and had a C++ lib which was shared between iOS and Android. I've also developed apps for iOS that were probably 95%+ C++.
BTW, your question is actually a bit vague. If you are talking libs, you should specify what areas you are looking to solve for. Your solution will vary based on your goals.

How to create an installer using Java? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
How to create an own installer using Java? I am not asking about any Java installer software. Anyone knows the logic or method please tell me. Is there any API available for these?
In windows you can use Advanced Installer .
Advanced Installer is the only Windows Installer authoring tool with built-in support for Java applications, integrating them fully into the Windows OS and making them look and feel just like a native application.
Using Advanced Installer you can create MSI packages for your Java applications, and allow your application to use the Windows Installer features.
http://www.advancedinstaller.com/java.html
This is such a vague question. What do you want to install ? Options include:
the JRE ?
your application (a .jar) ?
Registry entries ?
Configuration files ?
There's no such Java API. If you need to install the JRE, then you could look at an existing deployment mechanism such as .rpm (others exist) and declare a dependency on a JRE. That way your chosen package manager will deploy all your pre-requisites.
This is a highly specialized topic, and I would be very surprised to see an answer here that satisfies your need for knowledge. If you are serious about this, you should be prepared to do your own work to research the concepts and implementation strategies.
Suggestions:
Survey what the existing tools do; e.g. by reading all of the available user documentation. It should be pretty obvious how they achieve most of the things that they do, at least from a high-level perspective.
Download the source code for one or more of the open-source products and read the code to figure out how it works / they work.
Start designing and building your own tool and develop your own practical knowledge.
Maybe start with the Windows Installer MSDN reference?

Getting Java and TWAIN to play together nicely [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I'm working on building an app to scan directly from TWAIN scanner to a Java applet. I'm already aware of Morena and JTwain, but they cost money. I need free. I could re-invent the wheel with JNI, but it seems like someone has probably already done this as a FOSS tool.
Is anyone familiar with a free tool that can get a Java applet to read directly from a TWAIN scanner?
Calling the TWAIN API from anything except C/C++ is going to be a major pain, it relies entirely on complicated C structures that you have to replicate exactly in memory. If you need only fairly basic scanning, you could use something like GitHub site to call my old free 'EZTwain Classic' DLL (google for eztw32.dll)
hm. I might have some homebrew available for it somewhere I could check, but for now: At our company, we basically gave up on this issue and implemented an (unfortunately win only) ActiveX solution: Site Link
I've actually purchased the chestysoft activeX control. Been using it for about 3 years. Works great but as with all ActiveX you are restricted to IE. And this one is 32-bit only.
I'm looking into a flash approach now. Since flash can capture from a camera why not from a scanner. If I remember I'll report back what I find.

Categories

Resources