2014年2月7日星期五

java web reading serial data problems

Now I have a project need to use : read data from peripherals can scan the bar code , and then displayed in jap page. .


write a separate program that reads , application runs in myeclipse using java, data can be read ,
But once in a servlet , an error occurs. . .
say two words below it . .
portId = CommPortIdentifier.getPortIdentifier ("COM1");
System.out.println (portId.getName ());

put it on when the main function or as a java application running unit tests with Junit do is to find COM1 serial port of the machine, and then print out the name of the serial port , but these two words will appear in the wrong place servlet
java.lang.NoClassDefFoundError: javax / comm / CommPortIdentifier
these words are wrong, why not run in a servlet it? ? ?

want to read on the web to display data how to do ? looking for a day , out of the whole online search is the problem, there is no answer . . . .
I have three files that are copied to the appropriate folder , so the reading of that class can be run as a java application , but would not be placed in the servlet . . . .

or to individual ideas ? ? What other way can read serial data ? ? ?

seeking answers ! ! Thank
------ Solution --------------------------------------- -----

this is the little package.
jar package to the WEB-INF/lib directory of the project.
------ Solution ---------------------------------------- ----
upstairs that right, there is no definition, can not find java.lang.NoClassDefFoundError! Contain the library functions can be
------ Solution --------------------------------- -----------
such a test:
.
1 javax.comm.CommPortIdentifier.getPortIdentifie look at the main function call : each parameter (CommPortIdentifier.java 105) This line of execution
2 in the servlet execution , the same look javax.comm.CommPortIdentifier.getPortIdentifie.: each parameter (CommPortIdentifier.java 105) This line of execution. .

see what's not to like? Remove the cause of the details . .


------ Solution ------------------------------------ --------
http://www.blogjava.net/hgq0011/archive/2007/03/23/105726.html

------ For reference only ---------------------------------- -----

I've tried.
javax.comm.CommPortIdentifier comm.jar package in this class
placed under tomcat 's lib will be given after
javax.comm.NoSuchPortException
at javax.comm.CommPortIdentifier.getPortIdentifie (CommPortIdentifier.java: 105)
this newspaper is no serial port COM1 is definitely yes , but as a java application execution is possible to read the serial port . .
------ For reference only -------------------------------------- -
dynamic link libraries which need it? Canadian system32 directory.
------ For reference only -------------------------------------- -

morning came, and turn on the computer running again in despair , even better - !
really detailed , so fine I do not know why. .
Although I restart the computer yesterday, in addition to such other tomcat, myeclipse are restarted before. . . Engineering republish n times . .

Thank you again , although I do not know Why, but at least it is good. .
Nobody has points ^ _ ^
------ For reference only ------------------------ ---------------

solve this anthology little fake ah. Oh
------ For reference only ------------------------------------- -
LZ hello , I also get the project done java web serial data , but now have no idea , whether pointing or two ?

没有评论:

发表评论