Could not load main class in JavaCC - lexical-analysis

I am AI student and we work with JavaCC.
I am new with it. I was trying simple example and I had some errors.
1) I downloaded JavaCC 0.6 from it's website
2) I extracted it in disc C
3) I wrote this code in a file with extension ".jj"
PARSE_BEGIN(Test)
import java.io.*;
class Test
{
public static void main(string [] args)
{
new Test(new InputStreamReader(System.in));
start();
}
}
PARSE_END(Test);
Token:
{
<number: (["0"-"9"])+("." (["0"-"9"])+)?(("e"|"E")(["0"-"9"])+)?>|
<plus: "+">
}
void start():
{ }
{
<number>(<plus><number>)*
}
4) I saved it and put it in javacc/bin folder
5) I wrote this line in command
..."my Path"..javacc Test.jj
6) I had this error
Could not find or load main class javacc
Is there something I have to install before these steps?
thx in advance

Use version 5 at https://java.net/projects/javacc/downloads . Version 6.0 is missing the scripts to run JavaCC. If you really want to use version 6.0 you can find the appropriate scripts in version 5, just copy them to version 6's bin directory and away you go.
Update (2020): Since version 6 is now harder to find, I have put a copy at www.engr.mun.ca/~theo/JavaCC/javacc-6.1.0.zip

I selected the step you missed in bold below.
The download should have placed into your file system either a ZIP or
GZIP file containing the JavaCC software. You should go to the directory
where the archive was installed and unzip it's contents. That
completes your installation.
Once you have completed installation, add the bin directory within
the JavaCC installation to your path. The javacc, jjtree, and jjdoc
invocation scripts/executables reside in this directory.
You need to modify PATH system variable in windows (wild guess on used OS).
For example as described in
http://www.computerhope.com/issues/ch000549.htm
http://www.java.com/en/download/help/path.xml
...

Related

SWUpdate on RPi4 via yocto - error parsing configuration file

After booting SWUpdate yocto-generated image for the first time, executing swupdate results in error message:
Error parsing configuration file: 'globals' section missing, exiting.
I tried to strictly follow SWUpdate's documentation, but it gets short when it comes to yocto integration. I'm using meta-swupdate, meta-swupdate-boards, and meta-openembedded layers together with poky example repository all at Kirkstone tag, building via bitbake update-image and having modyfied local.conf as:
MACHINE ??= "raspberrypi4-64"
ENABLE_UART = "1"
RPI_USE_U_BOOT = "1"
IMAGE_FSTYPES = "wic ext4.gz"
PREFERRED_PROVIDER_u-boot-fw-utils = "libubootenv"
IMAGE_INSTALL:append = " swupdate"
Is there anything else I need to modify to generate the configuration file and be able to run SWUpdate binary properly?
Side question: In the documentation, it's recommended to append swupdate-www to achieve a better web server. However, if I append it, there is no swupdate-www binary inside the `/usr/bin' directory.
As with other recipes folders the recipes-support/swupdate/swupdate/raspberrypi4-64 folder was missing inside the meta-swupdate-boards layer. Therefore, an empty config file was always generated. After adding this folder and all related files, strongly inspired by raspberrypi3 folder, the error was gone and swupdate -h provided the expected output.
There was also one new error during build process thrown by yocto. It was related to missing systemd requirement and was solved by adding:
DISTRO_FEATURES_append = " systemd"
to local.conf

How to run a .pl test on C project in Eclipse on Windows?

I have to make a C (not C++) project to the specifications given by my teacher.
To allow us to test this project he has given us a .pl file that should test the project and a folder full of .in and .out files.
I work on a Win10 machine and has Eclipse for C installed (Kepler).
How can I set up my project to run the provided test?
Do I need to change anything in the test since I don't work on Linux and not from a cmdl?
The program is a train travel planner.
Here is the .pl file:
#!/usr/bin/env perl
use warnings;
use strict;
my ( $createmode ) = #ARGV;
my $testdir = "./tests";
if( defined($createmode) ) {
if($createmode cmp "create") {
print "Brug:\n";
print "\tcheck.pl - tests if your programs output matches .out-filerne\n";
print "\tcheck.pl create - makes new .out-files (deletes the excisting files!)\n";
exit();
}
$createmode=1;
}
# print "$testdir/tests.tst";
open(TESTS, "$testdir/tests.tst");
my $koereplan;
my $startst;
my $slutst;
while (<TESTS>) {
/([\w\d]+)\.in\s+\"(.+)\"\s+\"(.+)\"/ && do {
$koereplan="$testdir/$1";
$startst=$2;
$slutst=$3;
# print $koereplan."\t".$startst."\t".$slutst."\n";
open(RUN, "./travelplanning $koereplan.in '$startst' '$slutst' |");
my $cost=0;
while(<RUN>) {
/^(\d+)\s+(\d+)$/ && do {
$cost=$1+$2*15;
}
};
#print "Cost fra programmet: $cost";
my $outfile="$koereplan.$startst.$slutst.out";
# print $outfile."\n";
if($createmode) {
open(OUT, ">$outfile") or die "Couldn't open '$outfile' for writing";
} else {
open(IN, "<$outfile") or die "Couldn't open '$outfile' for reading";
}
if($createmode) {
print OUT "$cost\n";
} else {
my $facit=<IN>;
if($facit cmp "$cost\n") {
chomp $facit;
print "ERROR: $koereplan.in $startst $slutst gav $cost og facit er $facit.\n";
#last;
} else {
chomp $facit;
print "SUCCES: $koereplan.in $startst $slutst gav $cost og facit er $facit.\n";
};
};
};
}
Some names are in Danish, sorry about that. Koereplan = timetable, slut = end.
Excample of the .in files:
Esbjerg, 07:48
Bramming, 08:00
Vejen, 08:15
Kolding, 08:30
Middelfart, 08:45
Odense, 09:14
Nyborg, 09:29
Korsør, 09:42
Slagelse, 09:53
Sorø, 10:01
Ringsted, 10:10
Roskilde, 10:26
Høje Taastrup, 10:34
Valby, 10:42
København H, 10:48
This is just station names and departure times.
The .out files just contain one number each, the number of minutes the corresponding trip will take.
The scaffold project also came with makefile files, but I haven't been able to use them in my environment, I have simply taken the "business-files" to another project made in Eclipse, and that works fine for compiling and running the project in Eclipse. But that doesn't allow me to use the test script (that I currently can't even open in Eclipse).
If you feel it helps, here is the assignment: assignment on course website
But I think I can solve the assignment itself, it's using the teachers test I'm unsure about how to do.
To start Eclipse CDT choose 1 of these methods:
Start eclipse from the terminal that works, e.g.:
$ /path/to/eclipse.exe &
Make sure msys and mingw's bin directories are in the PATH and start eclipse the "normal" way
Then you can import your project as a new C Project and build/debug/run within CDT as normal:
Choose File menu | New | Makefile Project with Existing Code
Enter path to your project and name. But leave indexer settings as <none>* and press Finish
Open the Make Target view
Right-click on the project and choose New...
Fill in the target you want to build
Double-click on the new green icon and the build will run with the output in the Console view.
Something seems strange in CDT, if I use the obvious setting of MinGW GCC for indexer settings, then I can't do make properly as CDT is insisting on using internal builder.

connect QT 5.3 and postgresql

I'm a newbie in Qt (although I have some experience with C/C++/Java/PHP). I'm trying to migrate my older program that use PostgreSQL database into Qt GUI. I'm using PostgreSQL v2 and have downloaded the recent QT 5.3.0 (for MinGW 32-bit).
I created an example widget application, called Anu. The Anu.pro file looks like this :
QT += sql
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Anu
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
And the mainwindow.cpp looks like this :
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QSqlDatabase>
#include <QtSql>
#include <QMessageBox>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setHostName("localhost");
db.setDatabaseName("basicaccount");
db.setUserName("postgres");
db.setPassword("root");
db.setPort(5435);
bool ok = db.open();
if(ok != true)
{
QMessageBox::information(this,"Connection","Connection Failed!") ;
}
else
{
QMessageBox::information(this,"Connection","Connection OK!") ;
QSqlQueryModel model;
model.setQuery("select * from invoice ");
//ui->tableView->setModel(&model);
QMessageBox::information(this,"Information","This Message box is needed in order to see the rendered tableview!") ;
}
}
The error in compile shows QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7. I tried to build the plugin using the information here : http://qt-project.org/doc/qt-5/sql-driver.html. I opened the command prompt for Qt and put this :
cd E:\Qt\Qt5.3.0\5.3\mingw482_32\plugins\sqldrivers\psql
qmake "INCLUDEPATH+=E:\Program Files\PostgreSQL\9.2\include" "LIBS+=E:\Program Files\PostgreSQL\9.2\lib\libpq.lib" psql.pro
nmake
The problem is, I can't find the src folder or psql on folder sqldrivers. I've only found qsqlpsql.dll on that folder, and everytime I used it it says directory can't be found. Also, what's 'psql.pro' mean?
Thanks a lot for any help.
The most easy way, you need the following;
Depending on your application, 64 or 32 bit
If postgresql is 64 or 32 bit it doesn't matter, as the mingw is configured for 32 bit applications.
You need the 32 bit dlls,
If your version of postgre is 32 bit, then copy following dll's from your postgresql installations bin folder libeay32.dll, libintl.dll, libpq.dll, and ssleay32.dll, to your qt version mingw bin folder, now your program should work
If postgresql is 64 bit, the the included dll's doesn't work out of the box these are 64 bit !
You can still use 64 bit postgresql DB, no problem but you need the 32 bits dll's for your application.
There are more sophisticated ways to do this but to kick start your application this is considered the fastest.

Automatically log error and terminate application with SmartAssembly

I'm using SmartAssembly for both general code obfuscation as well as error reporting in an application.
If my application encounters an unhandled exception, I'd like the exception to be logged and then terminate the application without any user interaction. Is it possible to create a SmartAssembly project that allows this?
I've tried setting up the project in the SmartAssembly GUI, as well as on the command-line with no luck. Below is the command and arguments I've tried, but so far I can't determine how to get it to both terminate the app and log the error with no user input.
Create SA Project:
"C:\Program Files\Red Gate\SmartAssembly 6\SmartAssembly.com"
/create shell.saproj input=C:\Repositories\MyApp\src\shell.exe
/output=shell.exe
/reportappname="MyTestApp"
/errorreportingtemplate=standard;continueonerror=false,email:"my#email.com"
/reportprojectname="Shell"
/reportcompanyname="My Company"
Build the project:
"C:\Program Files\Red Gate\SmartAssembly 6\SmartAssembly.com" /build shell.saproj
SmartAssembly includes a few examples of custom ErrorReportingTemplates,
located in Red Gate/SmartAssembly 6/SDK/Exception Reporting/
The examples are lumped into a few categories:
Without UI
Standard
Custom UI
Via Email
Secured Proxy
Silverlight
Silverlight Basic
In each of these folders, there is a .csproj file that one can extend to get their desired results.
Inside the Without UI folder is the project we're after, titled Sample 01 - Without User Interface.csproj
If you're just after a .dll to use and don't care about a re-usable solution, edit this file directly and use the resulting .dll file (the alternative being to create a new project, and pull in the reference to SmartAssembly.SmartExceptionsCore).
Edit the OnReportException function to look like the following:
protected override void OnReportException(ReportExceptionEventArgs e)
{
for (int i=0; i<3; i++)
{
if (e.SendReport()) break;
}
e.TryToContinue = false;
System.Diagnostics.Process proc = System.Diagnostics.Process.GetCurrentProcess();
proc.Kill();
}
Here's a Gist of the final result, if you're confused.
Create the project file with the GUI or via cmd:
"C:\Program Files\Red Gate\SmartAssembly 6\SmartAssembly.com"
/create shell.saproj input=C:\Repositories\MyApp\src\shell.exe
/output=shell.exe
/reportappname="MyTestApp"
/errorreportingtemplate=MySmartAssemblyLogger.dll;continueonerror=false,email:"my#email.com"
/reportprojectname="Shell"
/reportcompanyname="My Company"
Build with the GUI or via cmd:
"C:\Program Files\Red Gate\SmartAssembly 6\SmartAssembly.com" /build shell.saproj
According to the example on the website http://www.red-gate.com/supportcenter/Content/SmartAssembly/help/6.7/SA_UsingTheCommandLine
You should replace "standard" with "auto" and that is supposed to send the error report without the user dialog appearing.

Problems downloading expansion files

I've uploaded my app to google. It has been published. My main exp file was uploaded with app version code 2 and it still bears the same name. My main app is right now at version code 4 and is still using the main.2 exp file.
I've already tested the file with my app through debug.
I've created a test account and i'm signed in on the device with that account and tried downloading 20 minutes after creating that test account.
I believe my file size is correct too. I'm using the the size from the properties 155,630,535 bytes and set it to 155630535L. There is another one called as size on disk which I'm not using.
I've uploaded my apk over 12 hours ago.
Really don't know where I'm going wrong. The only thing I wonder about is my version name which is 1.13. Do I need to use this anywhere?
I'm having problems downloading my expansion files. Initially I was getting 'download failed because you may not have purchased this app'. Now after recompiling (export file) the apk file and uninstalling it and reinstalling it to my device, I've uploaded it to my publish account and now I get 'resources could not be found'. Please help...
ok. I've resolved my issues after a lot of struggling by myself.
First, it's the size of the file in bytes only and not the size of the file in bytes on the disk.
Secondly, they have moved the test account into settings. You need to create a test account.
Thirdly, the app needs to be saved in draft mode. The expansion files will not download while testing using the test account, if the app has been published.
I hope this will help someone.
Some helfull information for people that end up here in this post since there are some things that changed in the way apk expansions work and also if you are using Android Studio to make the libraries work.
NOTE 1
You can't use draft anymore as the link to get the expansion file won't be active yet. You have to upload a version to Alpha or Beta first with expansion file. (adding an expansion file is only possible from the second apk you upload and up) So make sure you see the apk expansion file listed when you click the details in the developer publish section under APK.
NOTE 2
If you are using android studio and want to make use of the downloader library don't just copy the package name and java files into your own app src directory. Import the downloader library in eclipse and choose export => gradle build files. Afterwards you can import the library as a module in android studio.
NOTE 3
Not sure of this but I also think it's neccesary to download the app atleast once through the play store and have access to it with the account on your test device. So if you are working with alpha create a google+ test group and add yourself or other test devices to it.
BTW
With these libraries it's pretty easy to implement the apk expansion download just make sure:
your activity (the one where you want to implement the downloading
of the expansion pack when the downloading has not been done
automatically) implements IDownloaderClient.
you set up the service & receiver and set them up in your manifest.
The BASE64_PUBLIC_KEY in the service class is correct. Upload the
first apk => look in Services and API's in the developer console
under your app => License code for this app.
This code is used to see if the expansion file can be found on the device:
boolean expansionFilesDelivered() {
for (XAPKFile xf : xAPKS) {
String fileName = Helpers.getExpansionAPKFileName(this, xf.mIsMain, xf.mFileVersion);
Log.i(TAG, "Expansion filename " +fileName);
if (!Helpers.doesFileExist(this, fileName, xf.mFileSize, false))
return false;
}
return true;
}
It uses the class XAPKS wich represents an expansion file, be it either a main or patch file, having a certain filesize(bytes) and associated with a apk version (the one it was first added in).
private static class XAPKFile {
public final boolean mIsMain; // true
public final int mFileVersion; //example 4
public final long mFileSize; //example 126515695L
// example => main expansion that was first introduced in apk version 4 and is 126515695 bytes in size
XAPKFile(boolean isMain, int fileVersion, long fileSize) {
mIsMain = isMain;
mFileVersion = fileVersion;
mFileSize = fileSize;
}
}
Its also quite easy to read movie files and other stuff directly from the expansion file using the zip tools that google has provided (com.android.vending.zipfile).
First get the expansionfile using the methods provided in the library, the paremeters are integers that represent your main expansion apk version (the apk version where the expansion pack you need was first added) and the patch apk version.
ZipResourceFile expansionFile = APKExpansionSupport.getAPKExpansionZipFile(context, APKX_MAIN_APK, APKX_PATCH_APK);
Video
For playing video directly from this zipresourcefile:
AssetFileDescriptor a = expansionFile.getAssetFileDescriptor(pathToFileInsideZip);
Now from this assetFileDescriptor you can get a FileDescriptor and use this in your mediaplayer, the correct syntax to get your mediaplayer to play the video also needs the second and third parameter.. Be it the startoffset and length you can get from the AssetFileDescriptor.
player.setDataSource(a.getFileDescriptor(), a.getStartOffset(), a.getLength());
Other
For all the other stuff (like images) you can just get an inputstream of the zipresourcefile:
expansionFile.getInputStream(pathToFileInsideZip);`
ALSO make sure you don't compress the videos in the zip for this to work!
for example not to compress .mp4 files:
zip -n .mp4 -r zipfile.zip . -x ".*" -x "*/.*"

Resources