|
سلام
من به یک سورس برا اسنیف کردن پکت نیاز دارم کسی هست کمک ما کنه
|
|
|
|
|
Sorry, but I don't read Farsi.
Veni, vidi, abiit domum
|
|
|
|
|
|
True; but getting that message across is not an easy task.
Veni, vidi, abiit domum
|
|
|
|
|
Hi, what I want to do is to capture live video from a webcam in this java application, but had an error when I run this set of code:
java.io.IOException: Could not connect to capture device
javax.media.NoDataSourceException: Error instantiating class: com.sun.media.protocol.vfw.DataSource : java.io.IOException: Could not connect to capture device
I had already put the jmf.jar into the lib folder.
<pre lang="java"> public class CamRecorder {
static VideoFormat videoFormat;
static AudioFormat audioFormat;
static CaptureDeviceInfo videoDevice;
static CaptureDeviceInfo audioDevice;
public static void main(String[] args) {
try {
Vector deviceList = CaptureDeviceManager.getDeviceList(new YUVFormat()); //get all media devices
CaptureDeviceInfo device = (CaptureDeviceInfo) deviceList.firstElement(); //in this computer the only capture device is in=built webcam stays at 0th position
Format[] formats = device.getFormats(); //get all formats
for (int x = 0; x < formats.length; x++) {
if (formats[x] != null && formats[x] instanceof VideoFormat) {
videoFormat = (VideoFormat) formats[x]; //take the video format
videoDevice = device;
}
/*if (formats[x] != null && formats[x] instanceof AudioFormat) {
audioFormat = (AudioFormat) formats[x]; //take the audio format
//audioDevice = device;
}*/
}
//create data sources
DataSource videoDataSource = Manager.createDataSource(device.getLocator());
deviceList = CaptureDeviceManager.getDeviceList(new VideoFormat(null)); //get all media devices
device = (CaptureDeviceInfo) deviceList.firstElement();
DataSource audioDataSource=Manager.createDataSource(device.getLocator());
DataSource[] dArray=new DataSource[1];
dArray[0]=videoDataSource;
//dArray[1]=audioDataSource;
DataSource mixedDataSource = Manager.createMergingDataSource(dArray);
//format for output
Format[] outputFormats=new Format[2];
outputFormats[0]=new VideoFormat(VideoFormat.YUV);
//outputFormats[1]=new AudioFormat(AudioFormat.LINEAR);
//output type
FileTypeDescriptor outputType=new FileTypeDescriptor(FileTypeDescriptor.MSVIDEO);
//settingup Processor
ProcessorModel processorModel=new ProcessorModel(mixedDataSource, outputFormats, outputType);
Processor processor=Manager.createRealizedProcessor(processorModel);
//settingup sink
DataSource outputDataSource=processor.getDataOutput();
MediaLocator destination=new MediaLocator("file:.\\testcam.avi");
DataSink dataSink=Manager.createDataSink(outputDataSource, destination);
dataSink.open();
//start sink + processor
Thread.sleep(4000);
dataSink.start();
processor.start();
Thread.sleep(4000);
dataSink.close();
processor.stop();
processor.close();
} catch (Exception ex) {
System.out.println(ex);
}
}
}
|
|
|
|
|
Hi I'm trying to teach myself java. I have been going well till i ran accross chapter 5. GridWorld part 1. I am new to IntelliJ, and need some help importing bugrunner.java.
My question is should i start a new project then import the file?
Thanks in advance
David
|
|
|
|
|
|
A five for the effort, but alas still can't import the project. I guess i'll move on to chapter 6 and hope I don't miss much.
Thanks anyway.
David
|
|
|
|
|
David C# Hobbyist. wrote: still can't import the project. Import into what? Have you tried just creating a new project and using copy and paste to add the source code?
Veni, vidi, abiit domum
|
|
|
|
|
how to write code for decision tree classification(Data mining topic) in java?
|
|
|
|
|
You need to provide more details of exactly what your problem is. If you are just looking for general information to help you then try http://www.codeproject.com/KB/java/[^].
Veni, vidi, abiit domum
|
|
|
|
|
how to write while
2 power 2 + 4 power 2 + 6 power 2 + 8 power 2
public static void main(String[] args) {
int i=1;
int f=0;
while (i <=8){
f=f+i;
i++;
}System.out.println(Math.pow(f, 2));
}
}
|
|
|
|
|
int i=0;
int f=0;
while(i<8){
i=i+2;
f+=(Math.pow(i, 2));
}
System.out.println(f);
|
|
|
|
|
The points are stored in MySQL database in data-type of MEDIUM-TEXT, these examples of the points (coordinates)stored in this form(Starting two points are moveTo and each line is a curve)
458.41016 425.70843 427.74316 392.55343 403.93516 370.91243
399.48516 366.83843 398.54916 368.02743 397.41516 372.27043
394.75116 382.25643 392.96616 392.69543 391.09516 402.03043
390.35916 405.62343 389.79116 406.92443 392.62616 409.52743
406.00316 421.83343 442.19716 458.07143 444.89016 482.76843
431.76716 528.31343 393.39116 574.56743 350.22516 594.56743
316.63916 610.12643 278.88716 614.34043 242.18316 610.35243
232.12112,609.27843 228.38012 619.29143 238.47016 621.92243
274.01216 631.28543 320.32416 637.73643 356.57416 628.91043
420.03416 613.46343 456.48216 533.71643 457.61616 470.82943
all the above points have same Object-ID.
So, my question is How can i create GeneralPath objects to draw the shapes, I know there's a method curveTo() used to Add a curved segment, defined by three new points, to the path by drawing a Bézier curve, and How can i use all these points(coordinates) to draw curve on JFrame also i have so many others i need to combine all of them together based on Object-ID's ?
The program is :
import java.sql.*;
public class selectStmt {
private static final String DB_DRIVER = "com.mysql.jdbc.Driver";
private static final String DB_CONNECTION = "jdbc:mysql://127.0.0.1:3306/abo";
private static final String DB_USER = "username";
private static final String DB_PASSWORD = "pswd";
public selectStmt(){
try {
selectRecordsFromTable();
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
private static void selectRecordsFromTable() throws SQLException {
Connection dbConnection = null;
PreparedStatement preparedStatement = null;
String selectSQL = "SELECT * FROM abo.pathitems where ObjectID=1";
try {
dbConnection = getDBConnection();
preparedStatement = dbConnection.prepareStatement(selectSQL);
ResultSet rs = preparedStatement.executeQuery();
while (rs.next()) {
}
} catch (SQLException e) {
System.out.println(e.getMessage());
} finally {
if (preparedStatement != null) {
preparedStatement.close();
}
if (dbConnection != null) {
dbConnection.close();
}
}
}
private static Connection getDBConnection() {
Connection dbConnection = null;
try {
Class.forName(DB_DRIVER);
} catch (ClassNotFoundException e) {
System.out.println(e.getMessage());
}
try {
dbConnection = DriverManager.getConnection(
DB_CONNECTION, DB_USER,DB_PASSWORD);
return dbConnection;
} catch (SQLException e) {
System.out.println(e.getMessage());
}
return dbConnection;
}
}
Thanks
|
|
|
|
|
Have you worked through the tutorials I suggested in answer to your previous questions on this same issue?
Veni, vidi, abiit domum
|
|
|
|
|
not really i didn't find time at all so much of other works, anyways i should spend time on that. Thank you
|
|
|
|
|
This is a three part problem. Don't mix database access code and business logic, that leads to confusing and platform-dependent code.
The three parts I see here are:
- Read the data out of the database
- Interpret the data in an appropriate form (e.g. split the string up and turn it into a double[])
- Draw shapes with the numeric arrays you retrieve.
I think it's reasonable to combine the first two, i.e. in your database reading loop (what you posted in the question) read the field, split it on space and call Double.parseDouble on each element (exception trapped of course). If you control the database format then you shouldn't be writing numbers as text, either have 6 columns if a path segment is always 6 numbers, or store it as a binary blob containing the array ... though I must admit I've stored lists of numbers like this before as well.
The database reading code should return data objects, in this case a List<double[]> or a List<PathSegment> where PathSegment encodes the six numbers. You should then use those data objects in calling drawing code.
Looking at this mess of a class though I think you want to start a bit slower and work your way through some language tutorials. You're mixing up static and instance state (why provide a constructor that only calls a static method?), not understanding the principle of separation of concerns, not following good practice re exception handling ... Writing a database-backed 3 tier system is quite difficult and if you don't have language practices worked out then you're going to keep breaking things.
|
|
|
|
|
I am looking for making a database program by myself, but I don't want to end up in a dead end for some reason, so I need ton of examples and even better the entire source code of a sample database program. Any good book for this?
I don't care about the theory. I just want to know how to make a db program and then focus on using design patterns to improve the code.
Also, I am looking for a good book on Java Swing so I end up knowing all the ins and outs of Java Swing. I want tons of examples.
|
|
|
|
|
Given your aspirations, you need to make a better effort than posting your requirements here. Go to your local bookshop and see what's on offer. Look at on-line bookstores such as Amazon, O'Reilly etc. Search Google. Work through the Java Tutorials[^]; and practice, practice, practice.
Veni, vidi, abiit domum
|
|
|
|
|
Please start with "o'Reilly - Learning Java".
And start the Swing-Thingy first. Databases are more abstract - you can do that later when you're hooked.
|
|
|
|
|
I am also understanding Java using
Java How To
-=Dietel=-
|
|
|
|
|
Hello! I Could Print Contents of Java JTable using Printer using the following Code:
MessageFormat header=new MessageFormat("Printing JTable Contents");
MessageFormat foot = new MessageFormat("Page(0,number,integer)");
try {
JTable1.print(JTable.PrintMode.NORMAL, header, foot);
}
catch (java.awt.print.PrinterException e) {
System.err.format("Error! Cannot Print. ", e.getMessage());
}
But, I Couldn't Print All Contents of Java JTextFields and JLabels Only on Form using Printer. Can Some One help me how to print all contents of JTextFields and their corresponding JLabels???? Thanks!!!
|
|
|
|
|
|
Hello! I was trying to print contents in JText Fields and their corresponding JLabels on paper using the following code:
Toolkit tkp = jPanel7.getToolkit();
PrintJob pjp = tkp.getPrintJob(this, null, null);
Graphics g = pjp.getGraphics();
jPanel7.printAll(g);
g.dispose();
pjp.end();
But it's not printing the contents; It only prints all visible components on the jPanel7.
Please try modifying the code so as to print contents of text fields and their corresponding labels only???
Thanks!!!
|
|
|
|
|
The documentation[^] statest that printAll will invoke print which will then cause the panel and all its constituent parts to be printed. I would suggest you use your debugger to try and discover why this is not working in your case.
Veni, vidi, abiit domum
|
|
|
|