I am using xuggler to play video files from my code and the following is a snippet from the main code:
This snippet produces an error :
//The window we'll draw the video on.
private static VideoImage mScreen = null;
private static void updateJavaWindow(BufferedImage javaImage)
{
mScreen.setImage(javaImage);
}
// Opens a Swing window on screen.
private static void openJavaWindow()
{
mScreen = new VideoImage();
}
The error that i get is : cannot find symbol : class VideoImage
The header files used are :
import java.awt.image.BufferedImage;
import com.xuggle.xuggler.Global;
import com.xuggle.xuggler.IContainer;
import com.xuggle.xuggler.IPacket;
import com.xuggle.xuggler.IPixelFormat;
import com.xuggle.xuggler.IStream;
import com.xuggle.xuggler.IStreamCoder;
import com.xuggle.xuggler.ICodec;
import com.xuggle.xuggler.IVideoPicture;
import com.xuggle.xuggler.IVideoResampler;
import com.xuggle.xuggler.Utils;
Am i missing in some import statement ? If not , here are the libraries i am using apart from JDK :
What is the reason i am getting that error ?
VideoImage Javadoc
You are not importing the right class.
com.xuggle.xuggler.demos.VideoImage
It seems like you are already using an IDE. It should automatically tell you what import you are missing if the correct library is in the build path.
You need to import the VideoImage class.
Related
I'm coding a Minecraft mod and ran into an error when trying to start Ore Generation. The error is on the word "register" and the only action is Rename Reference. Here is my code.
package com.monkeyminers.mod1.world.feature;
import net.minecraft.core.Holder;
import net.minecraft.data.worldgen.placement.PlacementUtils;
import net.minecraft.world.level.levelgen.VerticalAnchor;
import net.minecraft.world.level.levelgen.placement.HeightRangePlacement;
import net.minecraft.world.level.levelgen.placement.PlacedFeature;
public class ModPlacedFeatures {
public static final Holder<PlacedFeature> CITRINE_ORE_PLACED =
PlacementUtils.register("graphene_ore_placed",
ModConfiguredFeatures.GRAPHENE_ORE, ModOrePlacement.commonOrePlacement(1, //
VeinsPerChunk
HeightRangePlacement.triangle(VerticalAnchor.aboveBottom(-80),
VerticalAnchor.aboveBottom(80))));
}
I am using OpenCSV in an Android Java project with IntelliJ.
I am trying to run the following code to create a bean inside my project. Note the segment surrounded by "** **"
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import androidx.appcompat.app.AppCompatActivity;
import com.opencsv.bean.CsvToBeanBuilder;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity implements View.OnClickListener
{
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main_page);
**List<Restrictions> restrictionData = new CsvToBeanBuilder(FileReader("restrictions.csv"))
.withType(Restrictions.class).build.parse();**
}
}
I have taken this code from OpenCSV's site where they say:
Here we simply name the fields identically to the header names. After
that, reading is a simple job:
List beans = new CsvToBeanBuilder(FileReader("yourfile.csv"))
.withType(Visitors.class).build().parse();
This will give you a list of the two beans as defined in the example input file. Note how type conversions to basic data types (wrapped and unwrapped primitives, enumerations, and Strings) occur automatically.
My code resembles their same style. Here is the error I get:
C:\Programming\Android\GoTimeJavaVersion\app\src\main\java\com\example\gotimejavaversion\MainActivity.java:34: error: cannot find symbol
List<Restrictions> restrictionData = new CsvToBeanBuilder(FileReader("restrictions.csv"))
^
symbol: method FileReader(String)
location: class MainActivity
I have tried putting 'new' in front of FileReader, and when I do this I get THIS error:
C:\Programming\Android\GoTimeJavaVersion\app\src\main\java\com\example\gotimejavaversion\MainActivity.java:35: error: cannot find symbol
.withType(Restrictions.class).build.parse();
^
symbol: variable build
location: class CsvToBeanBuilder
I have OpenCSV and beanutils in my library, both implemented in my build.gradle, and my file restrictions.csv is in my app's src folder. My Restrictions class also has no errors and follows OpenCSV's bean setup to a tee.
What am I doing wrong? Any help appreciated, thank you!
Use any of the below constructors for CsvToBeanBuilder. Constructor you are using is not valid :-
CsvToBeanBuilder(CSVReader csvReader)
CsvToBeanBuilder(Reader reader)
example :-
CSVReader csvReader = new CSVReader(new FileReader("restrictions.csv"));
List<Restrictions> restrictionData = new CsvToBeanBuilder(csvReader)
.withType(Restrictions.class)
.build()
.parse();
I need to copy some sections of source code from a pdf-file to a java project using eclipse neon.
Let me give you a quick example of the problem. I have code which looks like the following in the pdf:
import java.sql.Timestamp;
import twitter4j.FilterQuery;
import twitter4j.Status;
import twitter4j.StatusAdapter;
import twitter4j.StatusDeletionNotice;
import twitter4j.StatusListener;
import twitter4j.TwitterException;
import twitter4j.TwitterStream;
import twitter4j.TwitterStreamFactory;
public final class PrintSampleStream extends StatusAdapter {
public static void main(String[] args) throws TwitterException{
...
But in the workspace it is shown like this:
import java.sql.Timestamp; import twitter4j.FilterQuery; import twitter4j.Status; import twitter4j.StatusAdapter; import twitter4j.StatusDeletionNotice; import twitter4j.StatusListener; import twitter4j.TwitterException; import twitter4j.TwitterStream; import twitter4j.TwitterStreamFactory; public final class PrintSampleStream extends StatusAdapter { public static void main(String[] args) throws TwitterException{
How can i format the code and make it readable? Because formatting the code by hand would take too long.
Thanks for any ideas
P.S. CTRL + Shift +F doesn't help
It's a whitespace issue in the PDF or it's copy operation.
You can replace string ; (semicolon+space) by ;+ newline using the Eclispe search/replace dialog. See In Eclipse, how do I replace a character by a new line?
You say that ctrl+shift+F doesn't work for you. There is another way to format editor contents.
Go to: Window > Preferences > Java > Editor > Save actions and check the options Perform the selected actions on save, Format source code, Format all lines. Apply changes and then make small change in the editor (just to make it dirty) and save. Editor should automatically format.
Note: I am using Eclipse Luna but I believe that preference structure will be similar in Neon.
As for the reflow issues when copy pasting, you can check if this article helps you solve it.
This process isn't automated but you could use some free online code beautifiers such as
http://www.freecodeformat.com/java-format.php
http://jsbeautifier.org/
You basically have to copy-paste your unformatted code into a text-box. You can then "beautify" the code, by clicking a button. It then generates a formatted code. It isn't perfect, but it makes your code a lot more readable.
Example input:
import java.sql.Timestamp; import twitter4j.FilterQuery; import twitter4j.Status; import twitter4j.StatusAdapter; import twitter4j.StatusDeletionNotice; import twitter4j.StatusListener;public final class PrintSampleStream extends StatusAdapter { public static void main(String[] args) throws TwitterException{
Example output:
import twitter4j.FilterQuery;
import twitter4j.Status;
import twitter4j.StatusAdapter;
import twitter4j.StatusDeletionNotice;
import twitter4j.StatusListener;
public final class PrintSampleStream extends StatusAdapter {
public static void main(String[] args) throws TwitterException {
I searched this error and tried all available solutions but still getting this error. I am new to android so please help to rectify and remove this error.
I am fully aware that this error is somewhat associated with .R file of android.
I am using eclipse and getting 2 error
1- "activity_main cannot be resolved or is not a field"
2- List is a raw type. Reference to generic type.
Following is MainActivity code. This code is written to calculate nearest located Latlong distance..
package com.example.latlong;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import android.R;
import android.app.Activity;
import android.location.Location;
import android.os.Bundle;
import android.os.Environment;
import com.opencsv.CSVReader;
import com.opencsv.CSVWriter;
public class MainActivity extends Activity {
Double latToCompare=0.0, longToCompare=0.0;
float shortestDistance = 0.0f;
Boolean isDistanceComparedFirstTime = true;
Boolean isFirstRowInCSV1 = true, isFirstRowInCSV2 = true;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); /////// Error1 Line
createDirIfNotExists("/windows/Pictures/LatLongFiles");
String csvFilename1 = Environment.getExternalStorageDirectory()+"/windows/Pictures/LatLongFiles/Data.csv";
String csvFilename2 = Environment.getExternalStorageDirectory()+"/windows/Pictures/LatLongFiles/SourceFile.csv";
String csvFilename3 = Environment.getExternalStorageDirectory()+"/windows/Pictures/LatLongFiles/OutputFile.csv";
CSVReader csvReader1 = null;
CSVReader csvReader2 = null;
CSVWriter csvWriter3 = null;
List csvFile2List = null; ///////////// Error2 Line
I know this error is not new to you android guys but i tried everything and still stuck on this error.. Thanks in advance..
Removed import android.R; And clean and rebuild your project
import your_application_package_name.R;
Error 1 indicates that the build system cannot find a layout file called "activity_main.xml". Verify that you have such a layout file.
Error 2 is simply a warning that informs you that you are using a raw type rather than a generic type. Add a type parameter that indicates the type of objects that are to reside in your list, e.g.:
List<YourTypeHere> csvFile2List = null;
Delete import.android.R; and in place of it, add import com.example.latlong.R; if com.example.latlong is your package name.
Or if this is not your package name, see your manifest file for the package name. And add import YourPackageName.R; instead of import.android.R; where YourPackageName is the name of your package.
I am trying to create a code which will convert images into video. I have surfed a lot and find some method to do it using javacv. now i am getting variable not found error in these lines.
recorder.setCodecID( CODEC_ID_MPEG1VIDEO);
recorder.setPixelFormat( PIX_FMT_YUV420P);
I have imported all the jar files into my library as well but still getting this error. Some quick help would be appreciated. I have gone through the below link for the importing the javacv into my workspace.
How to Import JavaCV libraries to Android Project
package com.example.photoaday;
import static com.googlecode.javacv.cpp.opencv_core.cvReleaseImage;
import static com.googlecode.javacv.cpp.opencv_highgui.cvLoadImage;
import static com.googlecode.javacv.cpp.opencv_highgui.cvShowImage;
import static com.googlecode.javacv.cpp.opencv_highgui.cvWaitKey;
import static com.googlecode.javacv.cpp.opencv_imgproc.CV_GAUSSIAN;
import static com.googlecode.javacv.cpp.opencv_imgproc.cvSmooth;
import com.googlecode.javacv.FFmpegFrameRecorder;
import com.googlecode.javacv.cpp.opencv_core;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class Recordvideo extends Activity {
// #Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.create);
opencv_core.IplImage img = cvLoadImage("/sdcard/folder/img1.jpg");
FFmpegFrameRecorder recorder = new FFmpegFrameRecorder("/sdcard/folder/test.mpeg",200,150);
try {
recorder.setCodecID( CODEC_ID_MPEG1VIDEO);
recorder.setFrameRate(30);
recorder.setPixelFormat( PIX_FMT_YUV420P);
recorder.start();
for (int i=0;i<100;i++)
{
recorder.record(img);
}
recorder.stop();
}
catch (Exception e){
e.printStackTrace();
}
}
}
I assume that your compiler gives error as follows
error: ‘CODEC_ID_MPEG1VIDEO’ was not declared in this scope
error: ‘PIX_FMT_YUV420P’ was not declared in this scope
then solution for error is
change : ‘CODEC_ID_MPEG1VIDEO’ to 'AV_CODEC_ID_MPEG1VIDEO'
change : ‘PIX_FMT_YUV420P’ to 'AV_PIX_FMT_YUV420P'